From 664396b0e550910cea50b7852066a04cc7fec3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Sun, 14 Dec 2014 12:59:22 +0100 Subject: 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. --- async/src/async.cpp | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'async/src/async.cpp') 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) JobBase::~JobBase() { } - -void JobBase::exec() -{ - mExecutor->exec(); -} - - -FutureBase::FutureBase() - : mFinished(false) - , mWaitLoop(nullptr) -{ -} - -FutureBase::FutureBase(const Async::FutureBase &other) - : mFinished(other.mFinished) - , mWaitLoop(other.mWaitLoop) -{ -} - -FutureBase::~FutureBase() -{ -} - -void FutureBase::setFinished() -{ - mFinished = true; - if (mWaitLoop && mWaitLoop->isRunning()) { - mWaitLoop->quit(); - } -} - -bool FutureBase::isFinished() const -{ - return mFinished; -} - -void FutureBase::waitForFinished() -{ - if (mFinished) { - return; - } - - mWaitLoop = new QEventLoop; - mWaitLoop->exec(QEventLoop::ExcludeUserInputEvents); - delete mWaitLoop; - mWaitLoop = 0; -} - -- cgit v1.2.3