Reuse the non blocking implementation for blocking one

Replace the implementation of blockingMappedReduced():
after calling non-blocking version of mappedReduced() we are getting
the future object, so we may call in sequence result(), which
will block and return the result when the all tasks are done.

The same is done with blockigMapped(), which calls blockingMappedReduced()
with a custom reduce function.

Looks like with this pattern we can reuse the non-blocking version
for implementing blocking version of mapped / filtered methods.

Task-number: QTBUG-83918
Change-Id: I7f240cfbd04834d551ff79d717b72194a26996d7
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
This commit is contained in:
Jarek Kobus 2020-05-14 18:46:15 +02:00
parent c49728eb27
commit 79fd1cb2c6
4 changed files with 248 additions and 252 deletions

View File

@ -127,29 +127,28 @@ QFuture<ResultType> filteredReduced(const Sequence &sequence,
}
#ifndef Q_CLANG_QDOC
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> filteredReduced(
QThreadPool *pool,
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> filteredReduced(QThreadPool *pool,
const Sequence &sequence,
KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(pool, sequence, keep, reduce, options);
return startFilteredReduced<ResultType>(pool, sequence, keep, reduce, options);
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> filteredReduced(
const Sequence &sequence,
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> filteredReduced(const Sequence &sequence,
KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(QThreadPool::globalInstance(), sequence, keep, reduce, options);
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
sequence, keep, reduce, options);
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
@ -241,9 +240,9 @@ QFuture<ResultType> filteredReduced(Iterator begin,
}
#ifndef Q_CLANG_QDOC
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> filteredReduced(
QThreadPool *pool,
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
@ -251,21 +250,20 @@ QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> filtere
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(pool, begin, end, keep, reduce, options);
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce, options);
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> filteredReduced(
Iterator begin,
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> filteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(QThreadPool::globalInstance(), begin, end, keep, reduce, options);
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
begin, end, keep, reduce, options);
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
@ -339,14 +337,16 @@ QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin,
template <typename Sequence, typename KeepFunctor>
void blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor keep)
{
filterInternal(pool, sequence, keep, QtPrivate::PushBackWrapper()).startBlocking();
QFuture<void> future = filterInternal(pool, sequence, keep, QtPrivate::PushBackWrapper());
future.waitForFinished();
}
template <typename Sequence, typename KeepFunctor>
void blockingFilter(Sequence &sequence, KeepFunctor keep)
{
filterInternal(QThreadPool::globalInstance(), sequence, keep, QtPrivate::PushBackWrapper())
.startBlocking();
QFuture<void> future = filterInternal(QThreadPool::globalInstance(), sequence, keep,
QtPrivate::PushBackWrapper());
future.waitForFinished();
}
// blocking filteredReduced() on sequences
@ -358,8 +358,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, sequence, keep, reduce, options)
.startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, sequence, keep,
reduce, options);
return future.result();
}
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
@ -369,8 +370,9 @@ ResultType blockingFilteredReduced(const Sequence &sequence,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
sequence, keep, reduce, options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
sequence, keep, reduce, options);
return future.result();
}
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
@ -384,8 +386,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, sequence, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, sequence, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor,
@ -398,34 +401,37 @@ ResultType blockingFilteredReduced(const Sequence &sequence,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), sequence, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
sequence, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
#ifndef Q_CLANG_QDOC
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFilteredReduced(
QThreadPool *pool,
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingFilteredReduced(QThreadPool *pool,
const Sequence &sequence,
KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(pool, sequence, keep, reduce, options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, sequence, keep,
reduce, options);
return future.result();
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFilteredReduced(
const Sequence &sequence,
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingFilteredReduced(const Sequence &sequence,
KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(QThreadPool::globalInstance(), sequence, keep, reduce, options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
sequence, keep, reduce, options);
return future.result();
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
@ -440,8 +446,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, sequence, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, sequence, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
@ -455,8 +462,9 @@ ResultType blockingFilteredReduced(const Sequence &sequence,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), sequence, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
sequence, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
#endif
@ -470,8 +478,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce, options)
.startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep,
reduce, options);
return future.result();
}
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
@ -482,11 +491,11 @@ ResultType blockingFilteredReduced(Iterator begin,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end, keep,
reduce, options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
begin, end, keep, reduce, options);
return future.result();
}
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
@ -499,8 +508,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor,
@ -514,14 +524,15 @@ ResultType blockingFilteredReduced(Iterator begin,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
#ifndef Q_CLANG_QDOC
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFilteredReduced(
QThreadPool *pool,
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingFilteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
@ -529,21 +540,23 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFiltered
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(pool, begin, end, keep, reduce, options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep,
reduce, options);
return future.result();
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingFilteredReduced(
Iterator begin,
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingFilteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(QThreadPool::globalInstance(), begin, end, keep, reduce, options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
begin, end, keep, reduce, options);
return future.result();
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
@ -558,8 +571,9 @@ ResultType blockingFilteredReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
@ -574,8 +588,9 @@ ResultType blockingFilteredReduced(Iterator begin,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
QFuture<ResultType> future = startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
#endif
@ -583,30 +598,30 @@ ResultType blockingFilteredReduced(Iterator begin,
template <typename Sequence, typename KeepFunctor>
Sequence blockingFiltered(QThreadPool *pool, const Sequence &sequence, KeepFunctor keep)
{
return startFilteredReduced<Sequence>(pool, sequence, keep, QtPrivate::PushBackWrapper(),
OrderedReduce).startBlocking();
return blockingFilteredReduced<Sequence>(pool, sequence, keep, QtPrivate::PushBackWrapper(),
OrderedReduce);
}
template <typename Sequence, typename KeepFunctor>
Sequence blockingFiltered(const Sequence &sequence, KeepFunctor keep)
{
return startFilteredReduced<Sequence>(QThreadPool::globalInstance(), sequence, keep,
QtPrivate::PushBackWrapper(), OrderedReduce).startBlocking();
return blockingFilteredReduced<Sequence>(QThreadPool::globalInstance(), sequence, keep,
QtPrivate::PushBackWrapper(), OrderedReduce);
}
// blocking filtered() on iterators
template <typename OutputSequence, typename Iterator, typename KeepFunctor>
OutputSequence blockingFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor keep)
{
return startFilteredReduced<OutputSequence>(pool, begin, end, keep,
QtPrivate::PushBackWrapper(), OrderedReduce).startBlocking();
return blockingFilteredReduced<OutputSequence>(pool, begin, end, keep,
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename OutputSequence, typename Iterator, typename KeepFunctor>
OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)
{
return startFilteredReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end, keep,
QtPrivate::PushBackWrapper(), OrderedReduce).startBlocking();
return blockingFilteredReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end, keep,
QtPrivate::PushBackWrapper(), OrderedReduce);
}
} // namespace QtConcurrent

View File

@ -136,30 +136,29 @@ QFuture<ResultType> mappedReduced(const Sequence &sequence,
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
template <typename Sequence, typename MapFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(
QThreadPool *pool,
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> mappedReduced(QThreadPool *pool,
const Sequence &sequence,
MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, sequence, map, reduce, options);
}
template <typename Sequence, typename MapFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> mappedReduced(
const Sequence &sequence,
MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), sequence, map, reduce, options);
}
@ -175,8 +174,7 @@ QFuture<ResultType> mappedReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, sequence, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options);
}
@ -192,9 +190,7 @@ QFuture<ResultType> mappedReduced(const Sequence &sequence,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), sequence, map, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
@ -258,9 +254,9 @@ QFuture<ResultType> mappedReduced(Iterator begin,
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(
QThreadPool *pool,
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
@ -268,22 +264,20 @@ QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedR
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, options);
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(
Iterator begin,
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> mappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce, options);
}
@ -291,8 +285,7 @@ template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(
QThreadPool *pool,
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
@ -301,9 +294,7 @@ QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedR
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options);
}
@ -312,8 +303,7 @@ template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(
Iterator begin,
QFuture<ResultType> mappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
@ -321,9 +311,7 @@ QFuture<typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedR
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
@ -372,26 +360,30 @@ QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> mapped(
template <typename Sequence, typename MapFunctor>
void blockingMap(QThreadPool *pool, Sequence &sequence, MapFunctor map)
{
startMap(pool, sequence.begin(), sequence.end(), map).startBlocking();
QFuture<void> future = startMap(pool, sequence.begin(), sequence.end(), map);
future.waitForFinished();
}
template <typename Sequence, typename MapFunctor>
void blockingMap(Sequence &sequence, MapFunctor map)
{
startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(), map).startBlocking();
QFuture<void> future = startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(), map);
future.waitForFinished();
}
// blockingMap() for iterator ranges
template <typename Iterator, typename MapFunctor>
void blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor map)
{
startMap(pool, begin, end, map).startBlocking();
QFuture<void> future = startMap(pool, begin, end, map);
future.waitForFinished();
}
template <typename Iterator, typename MapFunctor>
void blockingMap(Iterator begin, Iterator end, MapFunctor map)
{
startMap(QThreadPool::globalInstance(), begin, end, map).startBlocking();
QFuture<void> future = startMap(QThreadPool::globalInstance(), begin, end, map);
future.waitForFinished();
}
// blockingMappedReduced() for sequences
@ -403,9 +395,10 @@ ResultType blockingMappedReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, sequence, map, reduce, options).startBlocking();
(pool, sequence, map, reduce, options);
return future.result();
}
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
@ -415,9 +408,10 @@ ResultType blockingMappedReduced(const Sequence &sequence,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), sequence, map, reduce, options).startBlocking();
(QThreadPool::globalInstance(), sequence, map, reduce, options);
return future.result();
}
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
@ -431,10 +425,11 @@ ResultType blockingMappedReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, sequence, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options).startBlocking();
options);
return future.result();
}
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor,
@ -447,48 +442,47 @@ ResultType blockingMappedReduced(const Sequence &sequence,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), sequence, map, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options)
.startBlocking();
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
template <typename MapFunctor, typename ReduceFunctor, typename Sequence>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
QThreadPool *pool,
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingMappedReduced(QThreadPool *pool,
const Sequence &sequence,
MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(pool, sequence, map, reduce, options).startBlocking();
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, sequence, map, reduce, options);
return future.result();
}
template <typename MapFunctor, typename ReduceFunctor, typename Sequence>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
const Sequence &sequence,
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingMappedReduced(const Sequence &sequence,
MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(QThreadPool::globalInstance(), sequence, map, reduce, options).startBlocking();
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), sequence, map, reduce, options);
return future.result();
}
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
QThreadPool *pool,
ResultType blockingMappedReduced(QThreadPool *pool,
const Sequence &sequence,
MapFunctor map,
ReduceFunctor reduce,
@ -496,30 +490,29 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, sequence, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options).startBlocking();
options);
return future.result();
}
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
const Sequence &sequence,
ResultType blockingMappedReduced(const Sequence &sequence,
MapFunctor map,
ReduceFunctor reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), sequence, map, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
// blockingMappedReduced() for iterator ranges
@ -532,9 +525,10 @@ ResultType blockingMappedReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, options).startBlocking();
(pool, begin, end, map, reduce, options);
return future.result();
}
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
@ -545,9 +539,10 @@ ResultType blockingMappedReduced(Iterator begin,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce, options).startBlocking();
(QThreadPool::globalInstance(), begin, end, map, reduce, options);
return future.result();
}
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
@ -562,10 +557,11 @@ ResultType blockingMappedReduced(QThreadPool *pool,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options).startBlocking();
options);
return future.result();
}
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor,
@ -579,15 +575,16 @@ ResultType blockingMappedReduced(Iterator begin,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
QThreadPool *pool,
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
@ -595,33 +592,32 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(pool, begin, end, map, reduce, options).startBlocking();
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, options);
return future.result();
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
Iterator begin,
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
ResultType blockingMappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce, options).startBlocking();
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce, options);
return future.result();
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
QThreadPool *pool,
ResultType blockingMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
@ -630,19 +626,18 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options).startBlocking();
options);
return future.result();
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(
Iterator begin,
ResultType blockingMappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
@ -650,11 +645,11 @@ typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedRe
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>,
typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> future = QtConcurrent::startMappedReduced
<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options).startBlocking();
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.result();
}
// mapped() for sequences with a different putput sequence type.

View File

@ -127,17 +127,15 @@ void testFilterThreadPool(QThreadPool *pool,
FilterObject filterObject)
{
QList<SourceObject> copy1 = sourceObjectList;
// QList<SourceObject> copy2 = sourceObjectList;
QList<SourceObject> copy2 = sourceObjectList;
QtConcurrent::filter(pool, copy1, filterObject).waitForFinished();
QCOMPARE(copy1, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// TODO: enable when QTBUG-83918 is fixed
// QtConcurrent::blockingFilter(pool, copy2, filterObject);
// QCOMPARE(copy2, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
QtConcurrent::blockingFilter(pool, copy2, filterObject);
QCOMPARE(copy2, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
}
class KeepOddIntegers
@ -244,17 +242,15 @@ void testFilteredThreadPool(QThreadPool *pool,
QCOMPARE(result2, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// TODO: enable when QTBUG-83918 is fixed
const QList<ResultObject> result3 = QtConcurrent::blockingFiltered(
pool, sourceObjectList, filterObject);
QCOMPARE(result3, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const QList<ResultObject> result3 = QtConcurrent::blockingFiltered(
// pool, sourceObjectList, filterObject);
// QCOMPARE(result3, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const QList<ResultObject> result4 = QtConcurrent::blockingFiltered<QList<ResultObject>>(
// pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(), filterObject);
// QCOMPARE(result4, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
const QList<ResultObject> result4 = QtConcurrent::blockingFiltered<QList<ResultObject>>(
pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(), filterObject);
QCOMPARE(result4, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
}
void tst_QtConcurrentFilter::filteredThreadPool()
@ -436,18 +432,16 @@ void testFilteredReducedThreadPool(QThreadPool *pool,
QCOMPARE(result2, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// TODO: enable when QTBUG-83918 is fixed
const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
pool, sourceObjectList, filterObject, reduceObject);
QCOMPARE(result3, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
// pool, sourceObjectList, filterObject, reduceObject);
// QCOMPARE(result3, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
// pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
// filterObject, reduceObject);
// QCOMPARE(result4, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
filterObject, reduceObject);
QCOMPARE(result4, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
}
void tst_QtConcurrentFilter::filteredReducedThreadPool()
@ -711,18 +705,16 @@ void testFilteredReducedInitialValueThreadPool(QThreadPool *pool,
QCOMPARE(result2, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// TODO: enable when QTBUG-83918 is fixed
const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
pool, sourceObjectList, filterObject, reduceObject, initialObject);
QCOMPARE(result3, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result3 = QtConcurrent::blockingFilteredReduced<ResultObject>(
// pool, sourceObjectList, filterObject, reduceObject, initialObject);
// QCOMPARE(result3, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
// pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
// filterObject, reduceObject, initialObject);
// QCOMPARE(result4, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
const ResultObject result4 = QtConcurrent::blockingFilteredReduced<ResultObject>(
pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
filterObject, reduceObject, initialObject);
QCOMPARE(result4, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
}
void tst_QtConcurrentFilter::filteredReducedInitialValueThreadPool()

View File

@ -483,17 +483,15 @@ void testMappedThreadPool(QThreadPool *pool,
QCOMPARE(result2, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// TODO: enable when QTBUG-83918 is fixed
const QList<ResultObject> result3 = QtConcurrent::blockingMapped(pool,
sourceObjectList, mapObject);
QCOMPARE(result3, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const QList<ResultObject> result3 = QtConcurrent::blockingMapped(pool,
// sourceObjectList, mapObject);
// QCOMPARE(result3, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const QList<ResultObject> result4 = QtConcurrent::blockingMapped<QList<ResultObject>>(pool,
// sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject);
// QCOMPARE(result4, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
const QList<ResultObject> result4 = QtConcurrent::blockingMapped<QList<ResultObject>>(pool,
sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject);
QCOMPARE(result4, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
}
int multiplyBy3(int x)
@ -678,17 +676,15 @@ void testMappedReducedThreadPool(QThreadPool *pool,
QCOMPARE(result2, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// TODO: enable when QTBUG-83918 is fixed
const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(pool,
sourceObjectList, mapObject, reduceObject);
QCOMPARE(result3, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(pool,
// sourceObjectList, mapObject, reduceObject);
// QCOMPARE(result3, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(pool,
// sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject, reduceObject);
// QCOMPARE(result4, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(pool,
sourceObjectList.constBegin(), sourceObjectList.constEnd(), mapObject, reduceObject);
QCOMPARE(result4, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
}
int intCube(int x)
@ -930,18 +926,16 @@ void testMappedReducedInitialValueThreadPool(QThreadPool *pool,
QCOMPARE(result2, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// TODO: enable when QTBUG-83918 is fixed
const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
pool, sourceObjectList, mapObject, reduceObject, initialObject);
QCOMPARE(result3, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result3 = QtConcurrent::blockingMappedReduced<ResultObject>(
// pool, sourceObjectList, mapObject, reduceObject, initialObject);
// QCOMPARE(result3, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
// const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
// pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
// mapObject, reduceObject, initialObject);
// QCOMPARE(result4, expectedResult);
// QCOMPARE(threadCount(), 1); // ensure the only one thread was working
const ResultObject result4 = QtConcurrent::blockingMappedReduced<ResultObject>(
pool, sourceObjectList.constBegin(), sourceObjectList.constEnd(),
mapObject, reduceObject, initialObject);
QCOMPARE(result4, expectedResult);
QCOMPARE(threadCount(), 1); // ensure the only one thread was working
}
void tst_QtConcurrentMap::mappedReducedInitialValueThreadPool()