From 4b18a8946bac34143a5eb85e669be01b8ced32fc Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 20 Mar 2025 13:23:41 +0100 Subject: docs: Clarify adding a continuation to a QFuture with multiple results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Explain that the continuation should take QFuture 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 Reviewed-by: MÃ¥rten Nordheim --- src/concurrent/qtconcurrentmap.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/concurrent/qtconcurrentmap.cpp') 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 -- cgit v1.2.3