diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-05-05 17:44:47 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-05-15 22:35:30 +0200 |
commit | 1a5cc8d13d0d348a571cab0d24dc814b896c8db7 (patch) | |
tree | f61154e733d74c5709549971bb7ce2edeb4ab453 /src/corelib/doc | |
parent | 612f6999c81a500a024f128bdf739342d659754a (diff) |
Add support of cancellation handler callbacks to QFuture
Added QFuture::onCanceled() method, for attaching handlers to be called
when the QFuture gets canceled.
Change-Id: I1f01647d6173ba0c1db6641e14140108b33ac7c4
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/doc')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp index 0580f142d7..da17b390fd 100644 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp @@ -220,3 +220,35 @@ QtFuture::connect(&object, &Object::singleArgSignal).then([](int value) { // handle other exceptions }); //! [14] + +//! [15] +QFuture<int> testFuture = ...; +auto resultFuture = testFuture.then([](int res) { + // Block 1 +}).onCanceled([] { + // Block 2 +}).onFailed([] { + // Block 3 +}).then([] { + // Block 4 +}).onFailed([] { + // Block 5 +}).onCanceled([] { + // Block 6 +}); +//! [15] + +//! [16] +QFuture<int> testFuture = ...; +auto resultFuture = testFuture.then([](int res) { + // Block 1 +}).onFailed([] { + // Block 3 +}).then([] { + // Block 4 +}).onFailed([] { + // Block 5 +}).onCanceled([] { + // Block 6 +}); +//! [16] |