summaryrefslogtreecommitdiffstats
path: root/src/concurrent/doc/snippets
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-09-30 16:42:47 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-10-28 15:38:52 +0100
commitc34673e5d918e1882401572f81d8c2d6f54c5459 (patch)
treee85108896b9cd29a035384846d50d423d79e1c73 /src/concurrent/doc/snippets
parentcf043a785ac9357e8f1283ea9e1496261af2b1a5 (diff)
QtConcurrent: Handle running with promise inside QTaskBuilder
Please note, that in case of run with promise it doesn't make sense to provide the overload taking the FutureResult, as if we are going to ignore the returned QFuture object, we can't communicate with the passed QPromise. Fixes: QTBUG-87083 Change-Id: I4066506736c2bbeea3e42030b9495f13e06cb27e Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/concurrent/doc/snippets')
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp
index b067b49e7e..267d6ebc1e 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp
@@ -129,3 +129,12 @@ QtConcurrent::task([]{ return 42; }).withPriority(10).spawn();
//! [11]
QtConcurrent::task([]{ qDebug("Hello, world!"); }).spawn(FutureResult::Ignore);
//! [11]
+
+//! [12]
+void increment(QPromise<int> &promise, int i)
+{
+ promise.addResult(i + 1);
+}
+
+int result = QtConcurrent::task(&increment).withArguments(10).spawn().result(); // result == 11
+//! [12]