summaryrefslogtreecommitdiffstats
path: root/async/src/async.h
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2015-04-11 11:44:49 +0200
committerDan Vrátil <dvratil@redhat.com>2015-04-11 11:44:49 +0200
commit73b8fe58c6fb985898d2bbf431926f0628e2b0a9 (patch)
tree5500fbfcca6ccc12cb744dd18c3f790e94f5fc9c /async/src/async.h
parent8d5f4e8485db0bfc0745a9852bac9eceab3b769f (diff)
downloadsink-73b8fe58c6fb985898d2bbf431926f0628e2b0a9.tar.gz
sink-73b8fe58c6fb985898d2bbf431926f0628e2b0a9.zip
Async: add runtime executor tracing for easier debugging
Diffstat (limited to 'async/src/async.h')
-rw-r--r--async/src/async.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/async/src/async.h b/async/src/async.h
index 2243046..73eeaa0 100644
--- a/async/src/async.h
+++ b/async/src/async.h
@@ -25,6 +25,7 @@
25#include <iterator> 25#include <iterator>
26 26
27#include "future.h" 27#include "future.h"
28#include "debug.h"
28#include "async_impl.h" 29#include "async_impl.h"
29 30
30#include <QVector> 31#include <QVector>
@@ -115,8 +116,13 @@ struct Execution {
115 bool isFinished; 116 bool isFinished;
116 117
117 ExecutionPtr prevExecution; 118 ExecutionPtr prevExecution;
119
120#ifndef QT_NO_DEBUG
121 Tracer *tracer;
122#endif
118}; 123};
119 124
125
120typedef QSharedPointer<Execution> ExecutionPtr; 126typedef QSharedPointer<Execution> ExecutionPtr;
121 127
122class ExecutorBase 128class ExecutorBase
@@ -128,6 +134,7 @@ class ExecutorBase
128 friend class Async::Job; 134 friend class Async::Job;
129 135
130 friend class Execution; 136 friend class Execution;
137 friend class Async::Tracer;
131 138
132public: 139public:
133 virtual ~ExecutorBase(); 140 virtual ~ExecutorBase();
@@ -143,6 +150,10 @@ protected:
143 virtual bool handleError(const ExecutionPtr &execution) = 0; 150 virtual bool handleError(const ExecutionPtr &execution) = 0;
144 151
145 ExecutorBasePtr mPrev; 152 ExecutorBasePtr mPrev;
153
154#ifndef QT_NO_DEBUG
155 QString mExecutorName;
156#endif
146}; 157};
147 158
148template<typename PrevOut, typename Out, typename ... In> 159template<typename PrevOut, typename Out, typename ... In>
@@ -581,6 +592,9 @@ ExecutionPtr Executor<PrevOut, Out, In ...>::exec(const ExecutorBasePtr &self)
581 // Passing 'self' to execution ensures that the Executor chain remains 592 // Passing 'self' to execution ensures that the Executor chain remains
582 // valid until the entire execution is finished 593 // valid until the entire execution is finished
583 ExecutionPtr execution = ExecutionPtr::create(self); 594 ExecutionPtr execution = ExecutionPtr::create(self);
595#ifndef QT_NO_DEBUG
596 execution->tracer = new Tracer(execution.data()); // owned by execution
597#endif
584 598
585 // chainup 599 // chainup
586 execution->prevExecution = mPrev ? mPrev->exec(mPrev) : ExecutionPtr(); 600 execution->prevExecution = mPrev ? mPrev->exec(mPrev) : ExecutionPtr();
@@ -667,6 +681,7 @@ ThenExecutor<Out, In ...>::ThenExecutor(ThenTask<Out, In ...> then, ErrorHandler
667 : Executor<typename detail::prevOut<In ...>::type, Out, In ...>(error, parent) 681 : Executor<typename detail::prevOut<In ...>::type, Out, In ...>(error, parent)
668 , mFunc(then) 682 , mFunc(then)
669{ 683{
684 STORE_EXECUTOR_NAME("ThenExecutor", Out, In ...);
670} 685}
671 686
672template<typename Out, typename ... In> 687template<typename Out, typename ... In>
@@ -686,6 +701,7 @@ EachExecutor<PrevOut, Out, In>::EachExecutor(EachTask<Out, In> each, ErrorHandle
686 : Executor<PrevOut, Out, In>(error, parent) 701 : Executor<PrevOut, Out, In>(error, parent)
687 , mFunc(each) 702 , mFunc(each)
688{ 703{
704 STORE_EXECUTOR_NAME("EachExecutor", PrevOut, Out, In);
689} 705}
690 706
691template<typename PrevOut, typename Out, typename In> 707template<typename PrevOut, typename Out, typename In>
@@ -727,6 +743,7 @@ template<typename Out, typename In>
727ReduceExecutor<Out, In>::ReduceExecutor(ReduceTask<Out, In> reduce, ErrorHandler errorFunc, const ExecutorBasePtr &parent) 743ReduceExecutor<Out, In>::ReduceExecutor(ReduceTask<Out, In> reduce, ErrorHandler errorFunc, const ExecutorBasePtr &parent)
728 : ThenExecutor<Out, In>(reduce, errorFunc, parent) 744 : ThenExecutor<Out, In>(reduce, errorFunc, parent)
729{ 745{
746 STORE_EXECUTOR_NAME("ReduceExecutor", Out, In);
730} 747}
731 748
732template<typename Out, typename ... In> 749template<typename Out, typename ... In>
@@ -734,6 +751,7 @@ SyncThenExecutor<Out, In ...>::SyncThenExecutor(SyncThenTask<Out, In ...> then,
734 : Executor<typename detail::prevOut<In ...>::type, Out, In ...>(errorFunc, parent) 751 : Executor<typename detail::prevOut<In ...>::type, Out, In ...>(errorFunc, parent)
735 , mFunc(then) 752 , mFunc(then)
736{ 753{
754 STORE_EXECUTOR_NAME("SyncThenExecutor", Out, In ...);
737} 755}
738 756
739template<typename Out, typename ... In> 757template<typename Out, typename ... In>
@@ -775,6 +793,7 @@ SyncEachExecutor<PrevOut, Out, In>::SyncEachExecutor(SyncEachTask<Out, In> each,
775 : Executor<PrevOut, Out, In>(errorFunc, parent) 793 : Executor<PrevOut, Out, In>(errorFunc, parent)
776 , mFunc(each) 794 , mFunc(each)
777{ 795{
796 STORE_EXECUTOR_NAME("SyncEachExecutor", PrevOut, Out, In);
778} 797}
779 798
780template<typename PrevOut, typename Out, typename In> 799template<typename PrevOut, typename Out, typename In>
@@ -812,6 +831,7 @@ template<typename Out, typename In>
812SyncReduceExecutor<Out, In>::SyncReduceExecutor(SyncReduceTask<Out, In> reduce, ErrorHandler errorFunc, const ExecutorBasePtr &parent) 831SyncReduceExecutor<Out, In>::SyncReduceExecutor(SyncReduceTask<Out, In> reduce, ErrorHandler errorFunc, const ExecutorBasePtr &parent)
813 : SyncThenExecutor<Out, In>(reduce, errorFunc, parent) 832 : SyncThenExecutor<Out, In>(reduce, errorFunc, parent)
814{ 833{
834 STORE_EXECUTOR_NAME("SyncReduceExecutor", Out, In);
815} 835}
816 836
817 837