diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-11-10 10:59:05 +0100 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-11-15 13:24:24 +0100 |
commit | 65d553ce522fa7fd906404f3259550a378603ad7 (patch) | |
tree | 78c20f94cda47f3cf524e243ad83babeae0987e7 /src/corelib/doc/snippets | |
parent | 76a551588c6756bfa9675d128c8a6e5a7cd50cb2 (diff) |
QFuture: extend the docs to explain how to cancel continuation chain
Task-number: QTBUG-97582
Change-Id: Ib31d0dfb7a74bb88802a21c5875edd789e412529
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/doc/snippets')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp | 17 |
1 files changed, 17 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 f4278abcbc..b8a4e708a5 100644 --- a/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_thread_qfuture.cpp @@ -294,3 +294,20 @@ auto continuation = future.then(context, [] (Results results) { // May or may not run in the context's thread }); //! [20] + +//! [21] +QFuture<int> testFuture = ...; +auto resultFuture = testFuture.then([](int res) { + // Block 1 + ... + return 1; +}).then([](int res) { + // Block 2 + ... + return 2; +}).onCanceled([] { + // Block 3 + ... + return -1; +}); +//! [21] |