summaryrefslogtreecommitdiffstats
path: root/async/src/async.cpp
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2015-04-01 21:02:34 +0200
committerDan Vrátil <dvratil@redhat.com>2015-04-01 21:19:48 +0200
commitb01fadba903056218f2a00c5e62e1dc8df062124 (patch)
treeadca72675973ab5d8253ab14ff94949824d6523e /async/src/async.cpp
parent94729eef71570e0b792a9afb95eeab7fd1eec56b (diff)
downloadsink-b01fadba903056218f2a00c5e62e1dc8df062124.tar.gz
sink-b01fadba903056218f2a00c5e62e1dc8df062124.zip
Async: support (re-)executing single Job multiple times
Storing Future and current Job progress directly in Executors means that we cannot re-execute finished job, or even execute the same Job multiple times in parallel. To do so, we need to make Executors stateless and track the state elsewhere. This change does that by moving the execution state from Executor to Execution class. Executors now only describe the tasks to execute, while Execution holds the current state of execution. New Execution is created every time Job::exec() is called. Execution holds reference to it's result (Future) and Executor which created the Execution. This ensures that Executor is not deleted when Job (which owns Executors) goes out of scope while the execution is still running. At the same time Future holds reference to relevant Execution, so that the Execution is deleted when all copies of Future referring result from the respective Execution are deleted.
Diffstat (limited to 'async/src/async.cpp')
-rw-r--r--async/src/async.cpp4
1 files changed, 0 insertions, 4 deletions
diff --git a/async/src/async.cpp b/async/src/async.cpp
index 20ba4e6..5e26bd8 100644
--- a/async/src/async.cpp
+++ b/async/src/async.cpp
@@ -26,15 +26,11 @@ using namespace Async;
26 26
27Private::ExecutorBase::ExecutorBase(const ExecutorBasePtr &parent) 27Private::ExecutorBase::ExecutorBase(const ExecutorBasePtr &parent)
28 : mPrev(parent) 28 : mPrev(parent)
29 , mResult(0)
30 , mIsRunning(false)
31 , mIsFinished(false)
32{ 29{
33} 30}
34 31
35Private::ExecutorBase::~ExecutorBase() 32Private::ExecutorBase::~ExecutorBase()
36{ 33{
37 delete mResult;
38} 34}
39 35
40 36