qt5base-lts/tests/auto/corelib/thread
Timur Pocheptsov 44ceb56455 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>
2020-03-31 15:28:23 +02:00
..
qatomicint Merge remote-tracking branch 'origin/dev' into wip/cmake 2019-11-19 13:53:21 +01:00
qatomicinteger cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
qatomicpointer Merge remote-tracking branch 'origin/dev' into wip/cmake 2019-11-19 13:53:21 +01:00
qfuture QFuture - add ability to move results from QFuture 2020-03-31 15:28:23 +02:00
qfuturesynchronizer cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
qfuturewatcher Regenerate projects one last time before merge 2020-02-12 17:30:49 +00:00
qmutex Regenerate projects one last time before merge 2020-02-12 17:30:49 +00:00
qmutexlocker cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
qreadlocker cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
qreadwritelock cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
qresultstore Regenerate projects one last time before merge 2020-02-12 17:30:49 +00:00
qsemaphore Merge remote-tracking branch 'origin/dev' into wip/cmake 2020-01-29 16:57:27 +01:00
qthread Regenerate tests/auto/corelib/thread 2019-11-12 17:25:29 +00:00
qthreadonce cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
qthreadpool Merge remote-tracking branch 'origin/5.15' into dev 2020-02-13 18:31:40 +01:00
qthreadstorage Post merge fixes 2019-11-25 14:53:27 +00:00
qwaitcondition cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
qwritelocker cmake: add more tests in corelib/thread 2019-10-04 06:27:19 +00:00
CMakeLists.txt cmake: add corelib/thread/qthreadstorage 2019-10-10 12:10:27 +00:00
thread.pro Re-enable thread autotests 2018-09-25 22:35:40 +00:00