summaryrefslogtreecommitdiffstats
path: root/src/concurrent
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2021-07-22 15:46:17 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2021-07-26 09:42:49 +0200
commitbd0d8a3adb98ff6f659e44e9a46decee32e9d94c (patch)
tree31727af982eb0a7d8493d0a42aa28ac0bc458723 /src/concurrent
parentc3a9c1ecbca15d2cab14e6c43cd683de4ad59b3a (diff)
Update QtConcurrent docs and examples for reductor object usage
After 6ebe3d0f0806069f906522dfe9b81baa3f3478de users don't have to specify the result type when using functors for as a reductor. Task-number: QTBUG-88448 Change-Id: I065fed11c1a66833ba0aac3d18e7ff0545247be1 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/concurrent')
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp10
-rw-r--r--src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp8
-rw-r--r--src/concurrent/qtconcurrentfilter.cpp8
-rw-r--r--src/concurrent/qtconcurrentmap.cpp8
4 files changed, 11 insertions, 23 deletions
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
index 0e0f414b13..b9ff35c798 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp
@@ -177,9 +177,7 @@ struct StringTransform
};
QFuture<QString> fooString =
- QtConcurrent::filteredReduced<QString>(strings,
- StartsWith(QLatin1String("Foo")),
- StringTransform());
+ QtConcurrent::filteredReduced(strings, StartsWith(QLatin1String("Foo")), StringTransform());
//! [14]
//! [15]
@@ -196,7 +194,7 @@ QList<int> results = future.results();
// add up all even integers
QList<int> list3 { 1, 2, 3, 4 };
-int sum = QtConcurrent::filteredReduced<int>(list3,
+QFuture<int> sum = QtConcurrent::filteredReduced(list3,
[](int x) {
return (x & 1) == 0;
},
@@ -213,7 +211,7 @@ void intSumReduce(int &sum, int x)
}
QList<int> list { 1, 2, 3, 4 };
-int sum = QtConcurrent::filteredReduced(list,
+QFuture<int> sum = QtConcurrent::filteredReduced(list,
[] (int x) {
return (x & 1) == 0;
},
@@ -228,7 +226,7 @@ bool keepEvenIntegers(int x)
}
QList<int> list { 1, 2, 3, 4 };
-int sum = QtConcurrent::filteredReduced<int>(list,
+QFuture<int> sum = QtConcurrent::filteredReduced(list,
keepEvenIntegers,
[](int &sum, int x) {
sum += x;
diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
index 659925a1c6..9c91715ac0 100644
--- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
+++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentmap.cpp
@@ -165,10 +165,8 @@ struct ImageTransform
};
QFuture<QImage> thumbNails =
- QtConcurrent::mappedReduced<QImage>(images,
- Scaled(100),
- ImageTransform(),
- QtConcurrent::SequentialReduce);
+ QtConcurrent::mappedReduced(images, Scaled(100), ImageTransform(),
+ QtConcurrent::SequentialReduce);
//! [11]
//! [13]
@@ -223,7 +221,7 @@ QList<QImage> collage = QtConcurrent::mappedReduced(images,
//! [16]
//! [17]
-QList<QImage> collage = QtConcurrent::mappedReduced<QImage>(images,
+QList<QImage> collage = QtConcurrent::mappedReduced(images,
[&size](const QImage &image) {
return image.scaled(size, size);
},
diff --git a/src/concurrent/qtconcurrentfilter.cpp b/src/concurrent/qtconcurrentfilter.cpp
index 2bec2a6eb9..663507be35 100644
--- a/src/concurrent/qtconcurrentfilter.cpp
+++ b/src/concurrent/qtconcurrentfilter.cpp
@@ -148,9 +148,7 @@
\snippet code/src_concurrent_qtconcurrentfilter.cpp 13
- For the reduce function, function objects are not directly
- supported. Function objects can, however, be used
- when the type of the reduction result is explicitly specified:
+ Function objects are also supported for the reduce function:
\snippet code/src_concurrent_qtconcurrentfilter.cpp 14
@@ -168,9 +166,7 @@
\snippet code/src_concurrent_qtconcurrentfilter.cpp 16
- For the reduce function, lambda expressions are not directly supported.
- Lambda expressions can, however, be used when the type of the reduction
- result is explicitly specified:
+ You can also pass a lambda as a reduce object:
\snippet code/src_concurrent_qtconcurrentfilter.cpp 17
diff --git a/src/concurrent/qtconcurrentmap.cpp b/src/concurrent/qtconcurrentmap.cpp
index d68dd63bb8..8abfec4baf 100644
--- a/src/concurrent/qtconcurrentmap.cpp
+++ b/src/concurrent/qtconcurrentmap.cpp
@@ -274,9 +274,7 @@
\snippet code/src_concurrent_qtconcurrentmap.cpp 14
- For the reduce function, function objects are not directly
- supported. Function objects can, however, be used
- when the type of the reduction result is explicitly specified:
+ Function objects are also supported for the reduce function:
\snippet code/src_concurrent_qtconcurrentmap.cpp 11
@@ -294,9 +292,7 @@
\snippet code/src_concurrent_qtconcurrentmap.cpp 16
- For the reduce function, lambda expressions are not directly supported.
- Lambda expressions can, however, be used when the type of the reduction
- result is explicitly specified:
+ You can also pass a lambda as a reduce object:
\snippet code/src_concurrent_qtconcurrentmap.cpp 17