diff options
author | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-10-13 15:18:08 +0200 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2020-10-14 21:24:31 +0200 |
commit | 0599255fcf54086ae345d289e8f761d890a91a39 (patch) | |
tree | e6bf5664c17cd2afa3da814ea3c7380261c18cb8 | |
parent | 9ded4739140e7e30aa386a9800c26afdbf952fd3 (diff) |
Simplify implementations of QtConcurrent::blocking* methods
Call non-blocking methods from the blocking ones.
Change-Id: Icf63637223533254b76826340334de35bca258b2
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
-rw-r--r-- | src/concurrent/qtconcurrentfilter.h | 67 | ||||
-rw-r--r-- | src/concurrent/qtconcurrentmap.h | 92 |
2 files changed, 70 insertions, 89 deletions
diff --git a/src/concurrent/qtconcurrentfilter.h b/src/concurrent/qtconcurrentfilter.h index 0552b8c0e3..286ff0c177 100644 --- a/src/concurrent/qtconcurrentfilter.h +++ b/src/concurrent/qtconcurrentfilter.h @@ -362,15 +362,14 @@ QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin, template <typename Sequence, typename KeepFunctor> void blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor keep) { - QFuture<void> future = filterInternal(pool, sequence, keep, QtPrivate::PushBackWrapper()); + QFuture<void> future = filter(pool, sequence, keep); future.waitForFinished(); } template <typename Sequence, typename KeepFunctor> void blockingFilter(Sequence &sequence, KeepFunctor keep) { - QFuture<void> future = filterInternal(QThreadPool::globalInstance(), sequence, keep, - QtPrivate::PushBackWrapper()); + QFuture<void> future = filter(sequence, keep); future.waitForFinished(); } @@ -383,8 +382,8 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( - pool, std::forward<Sequence>(sequence), keep, reduce, options); + QFuture<ResultType> future = filteredReduced<ResultType>(pool, std::forward<Sequence>(sequence), + keep, reduce, options); return future.takeResult(); } @@ -395,8 +394,8 @@ ResultType blockingFilteredReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( - QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce, options); + QFuture<ResultType> future = + filteredReduced<ResultType>(std::forward<Sequence>(sequence), keep, reduce, options); return future.takeResult(); } @@ -416,7 +415,7 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( + QFuture<ResultType> future = filteredReduced<ResultType>( pool, std::forward<Sequence>(sequence), keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); @@ -437,8 +436,8 @@ ResultType blockingFilteredReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( - QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce, + QFuture<ResultType> future = filteredReduced<ResultType>( + std::forward<Sequence>(sequence), keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -453,8 +452,8 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( - pool, std::forward<Sequence>(sequence), keep, reduce, options); + QFuture<ResultType> future = filteredReduced<ResultType>(pool, std::forward<Sequence>(sequence), + keep, reduce, options); return future.takeResult(); } @@ -466,8 +465,8 @@ ResultType blockingFilteredReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( - QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce, options); + QFuture<ResultType> future = + filteredReduced<ResultType>(std::forward<Sequence>(sequence), keep, reduce, options); return future.takeResult(); } @@ -483,7 +482,7 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( + QFuture<ResultType> future = filteredReduced<ResultType>( pool, std::forward<Sequence>(sequence), keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); @@ -500,8 +499,8 @@ ResultType blockingFilteredReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>( - QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce, + QFuture<ResultType> future = filteredReduced<ResultType>( + std::forward<Sequence>(sequence), keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -517,8 +516,8 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, - reduce, options); + QFuture<ResultType> future = + filteredReduced<ResultType>(pool, begin, end, keep, reduce, options); return future.takeResult(); } @@ -530,8 +529,7 @@ ResultType blockingFilteredReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(), - begin, end, keep, reduce, options); + QFuture<ResultType> future = filteredReduced<ResultType>(begin, end, keep, reduce, options); return future.takeResult(); } @@ -552,8 +550,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = filteredReduced<ResultType>( + pool, begin, end, keep, reduce, + ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -573,8 +572,9 @@ ResultType blockingFilteredReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(), - begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = filteredReduced<ResultType>( + begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), + options); return future.takeResult(); } @@ -589,8 +589,8 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, - reduce, options); + QFuture<ResultType> future = + filteredReduced<ResultType>(pool, begin, end, keep, reduce, options); return future.takeResult(); } @@ -603,8 +603,7 @@ ResultType blockingFilteredReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(), - begin, end, keep, reduce, options); + QFuture<ResultType> future = filteredReduced<ResultType>(begin, end, keep, reduce, options); return future.takeResult(); } @@ -620,8 +619,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = filteredReduced<ResultType>( + pool, begin, end, keep, reduce, + ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -637,8 +637,9 @@ ResultType blockingFilteredReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(), - begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = filteredReduced<ResultType>( + begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), + options); return future.takeResult(); } #endif diff --git a/src/concurrent/qtconcurrentmap.h b/src/concurrent/qtconcurrentmap.h index 29ab364e77..e6a434f852 100644 --- a/src/concurrent/qtconcurrentmap.h +++ b/src/concurrent/qtconcurrentmap.h @@ -435,9 +435,8 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (pool, std::forward<Sequence>(sequence), map, reduce, options); + QFuture<ResultType> future = + mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence), map, reduce, options); return future.takeResult(); } @@ -448,9 +447,8 @@ ResultType blockingMappedReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce, options); + QFuture<ResultType> future = + mappedReduced<ResultType>(std::forward<Sequence>(sequence), map, reduce, options); return future.takeResult(); } @@ -470,10 +468,9 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (pool, std::forward<Sequence>(sequence), map, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = mappedReduced<ResultType>( + pool, std::forward<Sequence>(sequence), map, reduce, + ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -492,10 +489,9 @@ ResultType blockingMappedReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = mappedReduced<ResultType>( + std::forward<Sequence>(sequence), map, reduce, + ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -508,9 +504,8 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (pool, std::forward<Sequence>(sequence), map, reduce, options); + QFuture<ResultType> future = + mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence), map, reduce, options); return future.takeResult(); } @@ -522,9 +517,8 @@ ResultType blockingMappedReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce, options); + QFuture<ResultType> future = + mappedReduced<ResultType>(std::forward<Sequence>(sequence), map, reduce, options); return future.takeResult(); } @@ -545,10 +539,9 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (pool, std::forward<Sequence>(sequence), map, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = mappedReduced<ResultType>( + pool, std::forward<Sequence>(sequence), map, reduce, + ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -568,10 +561,9 @@ ResultType blockingMappedReduced(Sequence &&sequence, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = mappedReduced<ResultType>( + std::forward<Sequence>(sequence), map, reduce, + ResultType(std::forward<InitialValueType>(initialValue)), options); return future.takeResult(); } @@ -585,9 +577,7 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (pool, begin, end, map, reduce, options); + QFuture<ResultType> future = mappedReduced<ResultType>(pool, begin, end, map, reduce, options); return future.takeResult(); } @@ -599,9 +589,7 @@ ResultType blockingMappedReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), begin, end, map, reduce, options); + QFuture<ResultType> future = mappedReduced<ResultType>(begin, end, map, reduce, options); return future.takeResult(); } @@ -622,10 +610,9 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)), - options); + QFuture<ResultType> future = mappedReduced<ResultType>( + pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)), + options); return future.takeResult(); } @@ -645,10 +632,9 @@ ResultType blockingMappedReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), begin, end, map, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = mappedReduced<ResultType>( + begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)), + options); return future.takeResult(); } @@ -662,9 +648,7 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (pool, begin, end, map, reduce, options); + QFuture<ResultType> future = mappedReduced<ResultType>(pool, begin, end, map, reduce, options); return future.takeResult(); } @@ -677,9 +661,7 @@ ResultType blockingMappedReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), begin, end, map, reduce, options); + QFuture<ResultType> future = mappedReduced<ResultType>(begin, end, map, reduce, options); return future.takeResult(); } @@ -701,10 +683,9 @@ ResultType blockingMappedReduced(QThreadPool *pool, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)), - options); + QFuture<ResultType> future = mappedReduced<ResultType>( + pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)), + options); return future.takeResult(); } @@ -725,10 +706,9 @@ ResultType blockingMappedReduced(Iterator begin, ReduceOptions options = ReduceOptions(UnorderedReduce | SequentialReduce)) { - QFuture<ResultType> future = QtConcurrent::startMappedReduced - <QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType> - (QThreadPool::globalInstance(), begin, end, map, reduce, - ResultType(std::forward<InitialValueType>(initialValue)), options); + QFuture<ResultType> future = mappedReduced<ResultType>( + begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)), + options); return future.takeResult(); } |