qt5base-lts/tests/auto/corelib/thread
Sona Kurazyan dfaca09e85 Add support for attaching continuations to QFuture
Added QFuture::then() methods to allow chaining multiple asynchronous
computations.

Continuations can use the following execution policies:

* QtFuture::Launch::Sync - the continuation will be launched in the same
thread in which the parent has been executing.

* QtFuture::Launch::Async - the continuation will be launched in a new
thread.

* QtFuture::Launch::Inherit - the continuation will inherit the launch
policy of the parent, or its thread pool (if it was using a custom one).

* Additionally then() also accepts a custom QThreadPool* instance.

Note, that if the parent future gets canceled, its continuation(s) will
be also canceled.

If the parent throws an exception, it will be propagated to the
continuation's future, unless it is caught inside the continuation
(if it has a QFuture arg).

Some example usages:

 QFuture<int> future = ...;
 future.then([](int res1){ ... }).then([](int res2){ ... })...

 QFuture<int> future = ...;
 future.then([](QFuture<int> fut1){ /* do something with fut1 */ })...

In the examples above all continuations will run in the same thread as
future.

 QFuture<int> future = ...;
 future.then(QtFuture::Launch::Async, [](int res1){ ... })
       .then([](int res2){ ... })..

In this example the continuations will run in a new thread (but on the
same one).

 QThreadPool pool;
 QFuture<int> future = ...;
 future.then(&pool, [](int res1){ ... })
       .then([](int res2){ ... })..

In this example the continuations will run in the given thread pool.

[ChangeLog][QtCore] Added support for attaching continuations to QFuture.

Task-number: QTBUG-81587
Change-Id: I5b2e176694f7ae8ce00404aca725e9a170818955
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-03-05 13:24:32 +01: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 Add support for attaching continuations to QFuture 2020-03-05 13:24:32 +01: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