qt5base-lts/tests/auto/corelib/thread
Arno Rehn 07d6d31a4c QFuture: Gracefully handle a destroyed context in continuations
This patch relaxes the requirements on the context object of
continuations. Instead of having to stay alive during execution of the
whole chain, it now only has to stay alive during setup of the chain.
If the context object is destroyed before the chain finishes, the
respective future is canceled.

This patch works by using QFutureCallOutInterface and signals instead
of direct invocation of the continuation by the parent future, similar
to how QFutureWatcher is implemented.
If a continuation is used with a context object, a QBasicFutureWatcher
is connected to the QFuture via a QFutureCallOutInterface. When the
future finishes, QBasicFutureWatcher::finished() triggers the
continuation with a signal/slot connection.
This way, we require the context object to stay alive only during setup;
the required synchronization is guaranteed by the existing event and
signal-slot mechanisms. The continuation itself does not need to know
about the context object anymore.

[ChangeLog][QtCore][QFuture] Added support for context objects of
continuations being destroyed before the continuation finishes. In
these cases the future is cancelled immediately.

Fixes: QTBUG-112958
Change-Id: Ie0ef3470b2a0ccfa789d2ae7604b92e509c14591
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-30 21:42:46 +02:00
..
qatomicint tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qatomicinteger tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qatomicpointer tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qfuture QFuture: Gracefully handle a destroyed context in continuations 2023-05-30 21:42:46 +02:00
qfuturesynchronizer tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qfuturewatcher Corelib: s/Q_OS_MAC/Q_OS_DARWIN/wg except for doc and definition 2023-03-20 19:18:52 +01:00
qmutex QSemaphore: add QDeadlineTimer API 2023-05-16 19:13:03 -07:00
qmutexlocker tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qpromise Long live QPromise::emplaceResult/At()! 2023-04-12 01:57:15 +02:00
qreadlocker tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qreadwritelock QThread: add sleep(std::chrono::nanoseconds) overload 2023-03-13 23:26:28 +02:00
qresultstore tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qsemaphore tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qthread QThread: add sleep(std::chrono::nanoseconds) overload 2023-03-13 23:26:28 +02:00
qthreadonce tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
qthreadpool tst_qthreadpool: expect a warning, cleaning up the test run 2023-05-04 19:40:32 +02:00
qthreadstorage Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
qwaitcondition QThread: add sleep(std::chrono::nanoseconds) overload 2023-03-13 23:26:28 +02:00
qwritelocker tests: Remove remains of qmake conversion from CMakeLists.txt files 2023-02-17 21:56:49 +01:00
CMakeLists.txt Rid of 'special case' markers 2023-04-13 18:30:58 +02:00