diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-08-16 20:37:09 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-08-16 20:37:09 +0300 |
commit | b7d91087099e4b69d70c0271fbeae19368d485d4 (patch) | |
tree | f46b62227cfeccf32b72f6aeb45c17cc7a933505 /src/concurrent/qtconcurrentmap.h | |
parent | 231d3670981a33ec42b91ad1cb33c1fc50551066 (diff) | |
parent | bbfbb18df18658e8ceec4bc04bd2cdf59f6a35ed (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.6' into tqtc/lts-5.15-opensource
Change-Id: Ia9164a17d80376f0a3ab9752c4a9f4dd2f0bd3d9
Diffstat (limited to 'src/concurrent/qtconcurrentmap.h')
-rw-r--r-- | src/concurrent/qtconcurrentmap.h | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/concurrent/qtconcurrentmap.h b/src/concurrent/qtconcurrentmap.h index 151f03cf56..70eea29bca 100644 --- a/src/concurrent/qtconcurrentmap.h +++ b/src/concurrent/qtconcurrentmap.h @@ -143,14 +143,16 @@ QFuture<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType> mapped( template <typename Sequence, typename MapFunctor> void blockingMap(Sequence &sequence, MapFunctor map) { - startMap(sequence.begin(), sequence.end(), QtPrivate::createFunctionWrapper(map)).startBlocking(); + QFuture<void> future = startMap(sequence.begin(), sequence.end(), QtPrivate::createFunctionWrapper(map)); + future.waitForFinished(); } // blockingMap() for iterator ranges template <typename Iterator, typename MapFunctor> void blockingMap(Iterator begin, Iterator end, MapFunctor map) { - startMap(begin, end, QtPrivate::createFunctionWrapper(map)).startBlocking(); + QFuture<void> future = startMap(begin, end, QtPrivate::createFunctionWrapper(map)); + future.waitForFinished(); } // blockingMappedReduced() for sequences @@ -160,12 +162,13 @@ ResultType blockingMappedReduced(const Sequence &sequence, ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType> + QFuture<ResultType> future = + QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType> (sequence, QtPrivate::createFunctionWrapper(map), QtPrivate::createFunctionWrapper(reduce), - options) - .startBlocking(); + options); + return future.result(); } template <typename MapFunctor, typename ReduceFunctor, typename Sequence> @@ -174,12 +177,13 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe ReduceFunctor reduce, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> + QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> future = + QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> (sequence, QtPrivate::createFunctionWrapper(map), QtPrivate::createFunctionWrapper(reduce), - options) - .startBlocking(); + options); + return future.result(); } // blockingMappedReduced() for iterator ranges @@ -190,12 +194,13 @@ ResultType blockingMappedReduced(Iterator begin, ReduceFunctor reduce, QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) { - return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType> + QFuture<ResultType> future = + QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, ResultType> (begin, end, QtPrivate::createFunctionWrapper(map), QtPrivate::createFunctionWrapper(reduce), - options) - .startBlocking(); + options); + return future.result(); } template <typename Iterator, typename MapFunctor, typename ReduceFunctor> @@ -205,12 +210,13 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe ReduceFunctor reduce, QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions(QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce)) { - return QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> + QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> future = + QtConcurrent::startMappedReduced<typename QtPrivate::MapResultType<void, MapFunctor>::ResultType, typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> (begin, end, QtPrivate::createFunctionWrapper(map), QtPrivate::createFunctionWrapper(reduce), - options) - .startBlocking(); + options); + return future.result(); } // mapped() for sequences with a different putput sequence type. |