diff options
| author | Ivan Solovev <ivan.solovev@qt.io> | 2025-03-20 13:23:41 +0100 |
|---|---|---|
| committer | Ivan Solovev <ivan.solovev@qt.io> | 2025-03-24 11:39:34 +0100 |
| commit | 4b18a8946bac34143a5eb85e669be01b8ced32fc (patch) | |
| tree | 1f3304fdef17b3a6343ef383e534634e6d23c747 /src/concurrent/qtconcurrentmap.cpp | |
| parent | 6a534cf5048ebb8b4641d4715a92be3ea0a6bb06 (diff) | |
docs: Clarify adding a continuation to a QFuture with multiple results
Explain that the continuation should take QFuture<T> as a parameter in
order to be able to access all results.
Add notes with examples to the QtConcurrent::mapped and
QtConcurrent::filtered overviews.
Task-number: QTBUG-133522
Pick-to: 6.9 6.8 6.5
Change-Id: I65655aadc8d4623b147d22a9bf9b2189c80b14c5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/concurrent/qtconcurrentmap.cpp')
| -rw-r--r-- | src/concurrent/qtconcurrentmap.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentmap.cpp b/src/concurrent/qtconcurrentmap.cpp index 222c8cd6396..31b71748812 100644 --- a/src/concurrent/qtconcurrentmap.cpp +++ b/src/concurrent/qtconcurrentmap.cpp @@ -168,6 +168,18 @@ return any results via QFuture. However, you can still use QFuture and QFutureWatcher to monitor the status of the map. + \section2 Concurrent Mapped and Continuations + + The result of QtConcurrent::mapped() call is a QFuture that contains + multiple results. When attaching a \c {.then()} continuation to such + QFuture, make sure to use a continuation that takes QFuture as a parameter, + otherwise only the first result will be processed: + + \snippet code/src_concurrent_qtconcurrentmap.cpp 18 + + In this example \c {badFuture} will only print a single result, while + \c {goodFuture} will print all results. + \section1 Concurrent Map-Reduce QtConcurrent::mappedReduced() is similar to QtConcurrent::mapped(), but |
