diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-06-02 10:48:06 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-06-04 22:32:43 +0200 |
commit | 37cfc3c6d2e3b290c7fc41cd7545283d24e4433c (patch) | |
tree | 91d3900ae5c113639467f3f47bd5217c42e29c2c /src/concurrent | |
parent | 036c3c19e7da5f1a280750d3c68a0cff38678029 (diff) |
Deprecate the pause-related APIs of QFuture* classes
Deprecated the pause-related APIs of QFuture* classes and
added alternatives having "suspend" in the name instead.
With 2f15927f01ceef0aca490746302a5ea57ea9441c new
isSuspended()/suspended() APIs have been added to QFuture* classes for
checking if pause/suspension is still in progress or it already took
effect. To keep the naming more consistent, renamed:
- setPaused() -> setSuspended()
- pause() -> suspend()
- togglePaused() -> toggleSuspended()
- QFutureWatcher::paused() -> QFutureWatcher::suspending()
Note that QFuture*::isPaused() now corresponds to (isSuspending() ||
isSuspended()).
[ChangeLog][Deprecation Notice] Deprecated pause-related APIs of
QFuture and QFutureWatcher. Added alternatives having "suspend" in
the name instead.
Change-Id: Ibeb75017a118401d64d18b72fb95d78e28c4661c
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/concurrent')
-rw-r--r-- | src/concurrent/qtconcurrentthreadengine.cpp | 10 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentthreadengine.h | 11 |
2 files changed, 13 insertions, 8 deletions
diff --git a/src/concurrent/qtconcurrentthreadengine.cpp b/src/concurrent/qtconcurrentthreadengine.cpp index 7ea606f60b..2c6e052621 100644 --- a/src/concurrent/qtconcurrentthreadengine.cpp +++ b/src/concurrent/qtconcurrentthreadengine.cpp @@ -219,9 +219,9 @@ void ThreadEngineBase::acquireBarrierSemaphore() barrier.acquire(); } -void ThreadEngineBase::reportIfPausedDone() const +void ThreadEngineBase::reportIfSuspensionDone() const { - if (futureInterface && futureInterface->isPaused()) + if (futureInterface && futureInterface->isSuspending()) futureInterface->reportSuspended(); } @@ -313,11 +313,11 @@ void ThreadEngineBase::run() // implements QRunnable. if (threadThrottleExit()) { return; } else { - // If the last worker thread is throttled and the state is paused, - // it means that pause has been requested, and it is already + // If the last worker thread is throttled and the state is "suspending", + // it means that suspension has been requested, and it is already // in effect (because all previous threads have already exited). // Report the "Suspended" state. - reportIfPausedDone(); + reportIfSuspensionDone(); } } diff --git a/src/concurrent/qtconcurrentthreadengine.h b/src/concurrent/qtconcurrentthreadengine.h index 4e7e8d0b81..82bff5fb3a 100644 --- a/src/concurrent/qtconcurrentthreadengine.h +++ b/src/concurrent/qtconcurrentthreadengine.h @@ -99,14 +99,19 @@ public: void setProgressValue(int progress); void setProgressRange(int minimum, int maximum); void acquireBarrierSemaphore(); - void reportIfPausedDone() const; + void reportIfSuspensionDone() const; protected: // The user overrides these: virtual void start() {} virtual void finish() {} virtual ThreadFunctionResult threadFunction() { return ThreadFinished; } - virtual bool shouldStartThread() { return futureInterface ? !futureInterface->isPaused() : true; } - virtual bool shouldThrottleThread() { return futureInterface ? futureInterface->isPaused() : false; } + virtual bool shouldStartThread() { return !shouldThrottleThread(); } + virtual bool shouldThrottleThread() + { + return futureInterface ? (futureInterface->isSuspending() || futureInterface->isSuspended()) + : false; + } + private: bool startThreadInternal(); void startThreads(); |