summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qfutureinterface_p.h
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2020-02-26 10:40:02 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2020-03-31 15:28:23 +0200
commit44ceb56455c82df3e6b1c9a2fa373cac14a039f8 (patch)
tree74f61f7adae376af0f2a9ee256a911e2bfc1ee9b /src/corelib/thread/qfutureinterface_p.h
parent986cfe312e4c01259f9a81c00dadebb10bc27ac9 (diff)
QFuture - add ability to move results from QFuture
QFuture's original design pre-dates C++11 and its introduction of move semantics. QFuture is documented as requiring copy-constructible classes and uses copy operations for results (which in Qt's universe in general is relatively cheap, due to the use of COW/data sharing). QFuture::result(), QFuture::results(), QFuture::resultAt() return copies. Now that the year is 2020, it makes some sense to add support for move semantics and, in particular, move-only types, like std::unique_ptr (that cannot be obtained from QFuture using result etc.). Taking a result or results from a QFuture renders it invalid. This patch adds QFuture<T>::takeResults(), takeResult() and isValid(). 'Taking' functions are 'enabled_if' for non-void types only to improve the compiler's diagnostic (which would otherwise spit some semi-articulate diagnostic). As a bonus a bug was found in the pre-existing code (after initially copy and pasted into the new function) - the one where we incorrectly report ready results in (rather obscure) filter mode. Fixes: QTBUG-81941 Fixes: QTBUG-83182 Change-Id: I8ccdfc50aa310a3a79eef2cdc55f5ea210f889c3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/thread/qfutureinterface_p.h')
-rw-r--r--src/corelib/thread/qfutureinterface_p.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h
index 306b02e269..95ad09d535 100644
--- a/src/corelib/thread/qfutureinterface_p.h
+++ b/src/corelib/thread/qfutureinterface_p.h
@@ -197,6 +197,7 @@ public:
QBasicMutex continuationMutex;
bool launchAsync = false;
+ bool isValid = false;
};
QT_END_NAMESPACE