diff options
Diffstat (limited to 'async/src/async.cpp')
-rw-r--r-- | async/src/async.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/async/src/async.cpp b/async/src/async.cpp index 5e26bd8..e92d333 100644 --- a/async/src/async.cpp +++ b/async/src/async.cpp | |||
@@ -21,9 +21,57 @@ | |||
21 | #include <QDebug> | 21 | #include <QDebug> |
22 | #include <QEventLoop> | 22 | #include <QEventLoop> |
23 | 23 | ||
24 | |||
25 | using namespace Async; | 24 | using namespace Async; |
26 | 25 | ||
26 | Private::Execution::Execution(const Private::ExecutorBasePtr &executor) | ||
27 | : executor(executor) | ||
28 | , resultBase(nullptr) | ||
29 | , isRunning(false) | ||
30 | , isFinished(false) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | Private::Execution::~Execution() | ||
35 | { | ||
36 | if (resultBase) { | ||
37 | resultBase->releaseExecution(); | ||
38 | delete resultBase; | ||
39 | } | ||
40 | prevExecution.reset(); | ||
41 | } | ||
42 | |||
43 | void Private::Execution::setFinished() | ||
44 | { | ||
45 | isFinished = true; | ||
46 | //executor.clear(); | ||
47 | #ifndef QT_NO_DEBUG | ||
48 | if (tracer) { | ||
49 | delete tracer; | ||
50 | } | ||
51 | #endif | ||
52 | } | ||
53 | |||
54 | void Private::Execution::releaseFuture() | ||
55 | { | ||
56 | resultBase = 0; | ||
57 | } | ||
58 | |||
59 | bool Private::Execution::errorWasHandled() const | ||
60 | { | ||
61 | Execution *exec = const_cast<Execution*>(this); | ||
62 | while (exec) { | ||
63 | if (exec->executor->hasErrorFunc()) { | ||
64 | return true; | ||
65 | } | ||
66 | exec = exec->prevExecution.data(); | ||
67 | } | ||
68 | return false; | ||
69 | } | ||
70 | |||
71 | |||
72 | |||
73 | |||
74 | |||
27 | Private::ExecutorBase::ExecutorBase(const ExecutorBasePtr &parent) | 75 | Private::ExecutorBase::ExecutorBase(const ExecutorBasePtr &parent) |
28 | : mPrev(parent) | 76 | : mPrev(parent) |
29 | { | 77 | { |
@@ -34,6 +82,8 @@ Private::ExecutorBase::~ExecutorBase() | |||
34 | } | 82 | } |
35 | 83 | ||
36 | 84 | ||
85 | |||
86 | |||
37 | JobBase::JobBase(const Private::ExecutorBasePtr &executor) | 87 | JobBase::JobBase(const Private::ExecutorBasePtr &executor) |
38 | : mExecutor(executor) | 88 | : mExecutor(executor) |
39 | { | 89 | { |