summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qfutureinterface.h
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-10-06 10:04:54 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2021-10-08 17:17:20 +0200
commitce59ccb3341223cda4f7ef2469d86326c6a116e8 (patch)
tree9084f53c7f50d349694a77a9e665a984ba1776de /src/corelib/thread/qfutureinterface.h
parent22248a4e96a49dbccfeb5c3deb26941a1f40a66e (diff)
Optimize QPromise destructor
Unify cancel and finish in QPromise destructor in a single call. This saves us one extra mutex lock and atomic state change. Task-number: QTBUG-84977 Change-Id: Iac06302c39a2863008b27325fcf6792d4f58c8ae Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/thread/qfutureinterface.h')
-rw-r--r--src/corelib/thread/qfutureinterface.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h
index ecc31d6ec35..e813031d594 100644
--- a/src/corelib/thread/qfutureinterface.h
+++ b/src/corelib/thread/qfutureinterface.h
@@ -154,6 +154,8 @@ public:
int loadState() const;
void cancel();
+ void cancelAndFinish() { cancel(CancelMode::CancelAndFinish); }
+
void setSuspended(bool suspend);
void toggleSuspended();
void reportSuspended() const;
@@ -216,6 +218,9 @@ protected:
bool launchAsync() const;
bool isRunningOrPending() const;
+
+ enum class CancelMode { CancelOnly, CancelAndFinish };
+ void cancel(CancelMode mode);
};
inline void swap(QFutureInterfaceBase &lhs, QFutureInterfaceBase &rhs) noexcept