summaryrefslogtreecommitdiffstats
path: root/async/src/async.cpp
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2014-12-14 12:59:22 +0100
committerDan Vrátil <dvratil@redhat.com>2014-12-14 13:03:38 +0100
commit664396b0e550910cea50b7852066a04cc7fec3bd (patch)
tree544f9e8206bd498fd16047211a833d01d65ac864 /async/src/async.cpp
parent925d3bd3159820c0eae356fe4d3af54cb16ae1e3 (diff)
downloadsink-664396b0e550910cea50b7852066a04cc7fec3bd.tar.gz
sink-664396b0e550910cea50b7852066a04cc7fec3bd.zip
Async: make the processing truly asynchronous
Now calling exec() starts the first job and returns a pending Future immediately. Caller can then use Async::FutureWatcher to wait for the future to become finished, i.e. for all jobs to finish execution.
Diffstat (limited to 'async/src/async.cpp')
-rw-r--r--async/src/async.cpp48
1 files changed, 0 insertions, 48 deletions
diff --git a/async/src/async.cpp b/async/src/async.cpp
index 0b8d7f3..e1d4806 100644
--- a/async/src/async.cpp
+++ b/async/src/async.cpp
@@ -48,51 +48,3 @@ JobBase::JobBase(Private::ExecutorBase *executor)
48JobBase::~JobBase() 48JobBase::~JobBase()
49{ 49{
50} 50}
51
52void JobBase::exec()
53{
54 mExecutor->exec();
55}
56
57
58FutureBase::FutureBase()
59 : mFinished(false)
60 , mWaitLoop(nullptr)
61{
62}
63
64FutureBase::FutureBase(const Async::FutureBase &other)
65 : mFinished(other.mFinished)
66 , mWaitLoop(other.mWaitLoop)
67{
68}
69
70FutureBase::~FutureBase()
71{
72}
73
74void FutureBase::setFinished()
75{
76 mFinished = true;
77 if (mWaitLoop && mWaitLoop->isRunning()) {
78 mWaitLoop->quit();
79 }
80}
81
82bool FutureBase::isFinished() const
83{
84 return mFinished;
85}
86
87void FutureBase::waitForFinished()
88{
89 if (mFinished) {
90 return;
91 }
92
93 mWaitLoop = new QEventLoop;
94 mWaitLoop->exec(QEventLoop::ExcludeUserInputEvents);
95 delete mWaitLoop;
96 mWaitLoop = 0;
97}
98