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>
This commit is contained in:
parent
9ded473914
commit
0599255fcf
@ -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,7 +550,8 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
|
||||
ReduceOptions options = ReduceOptions(UnorderedReduce
|
||||
| SequentialReduce))
|
||||
{
|
||||
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
|
||||
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,7 +619,8 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
|
||||
ReduceOptions options = ReduceOptions(UnorderedReduce
|
||||
| SequentialReduce))
|
||||
{
|
||||
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
|
||||
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
|
||||
|
@ -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,9 +468,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,
|
||||
QFuture<ResultType> future = mappedReduced<ResultType>(
|
||||
pool, std::forward<Sequence>(sequence), map, reduce,
|
||||
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
||||
return future.takeResult();
|
||||
}
|
||||
@ -492,9 +489,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,
|
||||
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,9 +539,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,
|
||||
QFuture<ResultType> future = mappedReduced<ResultType>(
|
||||
pool, std::forward<Sequence>(sequence), map, reduce,
|
||||
ResultType(std::forward<InitialValueType>(initialValue)), options);
|
||||
return future.takeResult();
|
||||
}
|
||||
@ -568,9 +561,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,
|
||||
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,9 +610,8 @@ 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)),
|
||||
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,9 +683,8 @@ 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)),
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user