Use universal references for passing callables in QtConcurrent

Task-number: QTBUG-87596
Change-Id: I219f08d73b97317820ec6e329ab1e6c89c0545f1
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Sona Kurazyan 2020-10-09 18:21:17 +02:00
parent ff0ba7e2d7
commit 4d9658b7cd
10 changed files with 1104 additions and 554 deletions

View File

@ -231,12 +231,12 @@
*/
/*!
\fn [QtConcurrent-1] template <typename Sequence, typename KeepFunctor, typename ReduceFunctor> ThreadEngineStarter<void> QtConcurrent::filterInternal(Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce)
\fn [QtConcurrent-1] template <typename Sequence, typename KeepFunctor, typename ReduceFunctor> ThreadEngineStarter<void> QtConcurrent::filterInternal(Sequence &sequence, KeepFunctor &&keep, ReduceFunctor &&reduce)
\internal
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> QFuture<void> QtConcurrent::filter(QThreadPool *pool, Sequence &sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> QFuture<void> QtConcurrent::filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -250,7 +250,7 @@
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> QFuture<void> QtConcurrent::filter(Sequence &sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> QFuture<void> QtConcurrent::filter(Sequence &sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence. If
\a filterFunction returns \c true, the item is kept in \a sequence;
@ -263,7 +263,7 @@
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> QFuture<Sequence::value_type> QtConcurrent::filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> QFuture<Sequence::value_type> QtConcurrent::filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence and returns a
new Sequence of kept items. All calls to \a filterFunction are invoked from the threads
@ -275,7 +275,7 @@
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> QFuture<Sequence::value_type> QtConcurrent::filtered(Sequence &&sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> QFuture<Sequence::value_type> QtConcurrent::filtered(Sequence &&sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence and returns a
new Sequence of kept items. If \a filterFunction returns \c true, a copy of
@ -286,7 +286,7 @@
*/
/*!
\fn template <typename Iterator, typename KeepFunctor> QFuture<typename QtConcurrent::qValueType<Iterator>::value_type> QtConcurrent::filtered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor filterFunction)
\fn template <typename Iterator, typename KeepFunctor> QFuture<typename QtConcurrent::qValueType<Iterator>::value_type> QtConcurrent::filtered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item from \a begin to \a end and
returns a new Sequence of kept items. All calls to \a filterFunction are invoked from the threads
@ -298,7 +298,7 @@
*/
/*!
\fn template <typename Iterator, typename KeepFunctor> QFuture<typename QtConcurrent::qValueType<Iterator>::value_type> QtConcurrent::filtered(Iterator begin, Iterator end, KeepFunctor filterFunction)
\fn template <typename Iterator, typename KeepFunctor> QFuture<typename QtConcurrent::qValueType<Iterator>::value_type> QtConcurrent::filtered(Iterator begin, Iterator end, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item from \a begin to \a end and
returns a new Sequence of kept items. If \a filterFunction returns \c true, a
@ -309,7 +309,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -328,7 +328,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -346,7 +346,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -368,7 +368,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -389,7 +389,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -408,7 +408,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -426,7 +426,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -448,7 +448,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -469,7 +469,7 @@
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> void QtConcurrent::blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> void QtConcurrent::blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -485,7 +485,7 @@
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> void QtConcurrent::blockingFilter(Sequence &sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> void QtConcurrent::blockingFilter(Sequence &sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence. If
\a filterFunction returns \c true, the item is kept in \a sequence;
@ -500,7 +500,7 @@
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> Sequence QtConcurrent::blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> Sequence QtConcurrent::blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence and returns a
new Sequence of kept items. All calls to \a filterFunction are invoked from the threads
@ -514,7 +514,7 @@
*/
/*!
\fn template <typename Sequence, typename KeepFunctor> Sequence QtConcurrent::blockingFiltered(Sequence &&sequence, KeepFunctor filterFunction)
\fn template <typename Sequence, typename KeepFunctor> Sequence QtConcurrent::blockingFiltered(Sequence &&sequence, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item in \a sequence and returns a
new Sequence of kept items. If \a filterFunction returns \c true, a copy of
@ -527,7 +527,7 @@
*/
/*!
\fn template <typename OutputSequence, typename Iterator, typename KeepFunctor> OutputSequence QtConcurrent::blockingFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor filterFunction)
\fn template <typename OutputSequence, typename Iterator, typename KeepFunctor> OutputSequence QtConcurrent::blockingFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item from \a begin to \a end and
returns a new Sequence of kept items. All calls to \a filterFunction are invoked from the threads
@ -542,7 +542,7 @@
*/
/*!
\fn template <typename OutputSequence, typename Iterator, typename KeepFunctor> OutputSequence QtConcurrent::blockingFiltered(Iterator begin, Iterator end, KeepFunctor filterFunction)
\fn template <typename OutputSequence, typename Iterator, typename KeepFunctor> OutputSequence QtConcurrent::blockingFiltered(Iterator begin, Iterator end, KeepFunctor &&filterFunction)
Calls \a filterFunction once for each item from \a begin to \a end and
returns a new Sequence of kept items. If \a filterFunction returns \c true, a
@ -556,7 +556,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -577,7 +577,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -597,7 +597,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -621,7 +621,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(Sequence &&sequence, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item in \a sequence. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -644,7 +644,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -666,7 +666,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -687,7 +687,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end.
All calls to \a filterFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -712,7 +712,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor filterFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a filterFunction once for each item from \a begin to \a end. If
\a filterFunction returns \c true for an item, that item is then passed to
@ -736,31 +736,31 @@
*/
/*!
\fn [QtConcurrent-2] ThreadEngineStarter<typename qValueType<Iterator>::value_type> QtConcurrent::startFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor functor)
\fn [QtConcurrent-2] ThreadEngineStarter<typename qValueType<Iterator>::value_type> QtConcurrent::startFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&functor)
\internal
*/
/*!
\fn [QtConcurrent-3] ThreadEngineStarter<typename Sequence::value_type> QtConcurrent::startFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor functor)
\fn [QtConcurrent-3] ThreadEngineStarter<typename Sequence::value_type> QtConcurrent::startFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&functor)
\internal
*/
/*!
\fn [QtConcurrent-4] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
\fn [QtConcurrent-4] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ReduceOptions options)
\internal
*/
/*!
\fn [QtConcurrent-5] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
\fn [QtConcurrent-5] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ReduceOptions options)
\internal
*/
/*!
\fn [QtConcurrent-6] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ResultType initialValue, ReduceOptions options)
\fn [QtConcurrent-6] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ResultType &&initialValue, ReduceOptions options)
\internal
*/
/*!
\fn [QtConcurrent-7] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ResultType initialValue, ReduceOptions options)
\fn [QtConcurrent-7] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ResultType &&initialValue, ReduceOptions options)
\internal
*/

View File

@ -54,48 +54,53 @@ namespace QtConcurrent {
//! [QtConcurrent-1]
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor>
ThreadEngineStarter<void> filterInternal(QThreadPool *pool, Sequence &sequence,
KeepFunctor keep, ReduceFunctor reduce)
KeepFunctor &&keep, ReduceFunctor &&reduce)
{
typedef FilterKernel<Sequence, KeepFunctor, ReduceFunctor> KernelType;
return startThreadEngine(new KernelType(pool, sequence, keep, reduce));
typedef FilterKernel<Sequence, std::decay_t<KeepFunctor>, std::decay_t<ReduceFunctor>>
KernelType;
return startThreadEngine(new KernelType(pool, sequence, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce)));
}
// filter() on sequences
template <typename Sequence, typename KeepFunctor>
QFuture<void> filter(QThreadPool *pool, Sequence &sequence, KeepFunctor keep)
QFuture<void> filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&keep)
{
return filterInternal(pool, sequence, keep, QtPrivate::PushBackWrapper());
return filterInternal(pool, sequence, std::forward<KeepFunctor>(keep),
QtPrivate::PushBackWrapper());
}
template <typename Sequence, typename KeepFunctor>
QFuture<void> filter(Sequence &sequence, KeepFunctor keep)
QFuture<void> filter(Sequence &sequence, KeepFunctor &&keep)
{
return filterInternal(QThreadPool::globalInstance(),
sequence, keep, QtPrivate::PushBackWrapper());
sequence, std::forward<KeepFunctor>(keep), QtPrivate::PushBackWrapper());
}
// filteredReduced() on sequences
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, std::forward<Sequence>(sequence), keep, reduce,
options);
return startFilteredReduced<ResultType>(pool, std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
}
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
QFuture<ResultType> filteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(
QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce, options);
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce), options);
}
#ifdef Q_CLANG_QDOC
@ -108,14 +113,15 @@ template <typename ResultType, typename Sequence, typename KeepFunctor, typename
#endif
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence), keep, reduce,
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
@ -128,73 +134,82 @@ template <typename ResultType, typename Sequence, typename KeepFunctor, typename
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
QFuture<ResultType> filteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(
QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce,
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
#ifndef Q_CLANG_QDOC
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, std::forward<Sequence>(sequence), keep, reduce,
options);
return startFilteredReduced<ResultType>(pool, std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> filteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(
QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce, options);
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce), options);
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence), keep, reduce,
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
QFuture<ResultType> filteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(
QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep, reduce,
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
#endif
@ -204,24 +219,26 @@ template <typename ResultType, typename Iterator, typename KeepFunctor, typename
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce, options);
return startFilteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
}
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
QFuture<ResultType> filteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end, keep, reduce,
options);
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end,
std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
}
#ifdef Q_CLANG_QDOC
@ -235,14 +252,15 @@ template <typename ResultType, typename Iterator, typename KeepFunctor, typename
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return startFilteredReduced<ResultType>(
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
#ifdef Q_CLANG_QDOC
@ -255,89 +273,102 @@ template <typename ResultType, typename Iterator, typename KeepFunctor, typename
#endif
QFuture<ResultType> filteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return startFilteredReduced<ResultType>(
QThreadPool::globalInstance(), begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
#ifndef Q_CLANG_QDOC
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce, options);
return startFilteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> filteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(),
begin, end, keep, reduce, options);
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end,
std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
QFuture<ResultType> filteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(pool, begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return startFilteredReduced<ResultType>(
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
QFuture<ResultType> filteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startFilteredReduced<ResultType>(QThreadPool::globalInstance(), begin, end, keep, reduce,
ResultType(std::forward<InitialValueType>(initialValue)), options);
return startFilteredReduced<ResultType>(
QThreadPool::globalInstance(), begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
#endif
// filtered() on sequences
template <typename Sequence, typename KeepFunctor>
QFuture<typename std::decay_t<Sequence>::value_type> filtered(QThreadPool *pool,
Sequence &&sequence, KeepFunctor keep)
QFuture<typename std::decay_t<Sequence>::value_type> filtered(QThreadPool *pool,Sequence &&sequence,
KeepFunctor &&keep)
{
return startFiltered(pool, std::forward<Sequence>(sequence), keep);
return startFiltered(pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep));
}
template <typename Sequence, typename KeepFunctor>
QFuture<typename std::decay_t<Sequence>::value_type> filtered(Sequence &&sequence, KeepFunctor keep)
QFuture<typename std::decay_t<Sequence>::value_type> filtered(Sequence &&sequence,
KeepFunctor &&keep)
{
return startFiltered(QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep);
return startFiltered(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(keep));
}
// filtered() on iterators
@ -345,31 +376,32 @@ template <typename Iterator, typename KeepFunctor>
QFuture<typename qValueType<Iterator>::value_type> filtered(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep)
KeepFunctor &&keep)
{
return startFiltered(pool, begin, end, keep);
return startFiltered(pool, begin, end, std::forward<KeepFunctor>(keep));
}
template <typename Iterator, typename KeepFunctor>
QFuture<typename qValueType<Iterator>::value_type> filtered(Iterator begin,
Iterator end,
KeepFunctor keep)
KeepFunctor &&keep)
{
return startFiltered(QThreadPool::globalInstance(), begin, end, keep);
return startFiltered(QThreadPool::globalInstance(), begin, end,
std::forward<KeepFunctor>(keep));
}
// blocking filter() on sequences
template <typename Sequence, typename KeepFunctor>
void blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor keep)
void blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&keep)
{
QFuture<void> future = filter(pool, sequence, keep);
QFuture<void> future = filter(pool, sequence, std::forward<KeepFunctor>(keep));
future.waitForFinished();
}
template <typename Sequence, typename KeepFunctor>
void blockingFilter(Sequence &sequence, KeepFunctor keep)
void blockingFilter(Sequence &sequence, KeepFunctor &&keep)
{
QFuture<void> future = filter(sequence, keep);
QFuture<void> future = filter(sequence, std::forward<KeepFunctor>(keep));
future.waitForFinished();
}
@ -377,25 +409,27 @@ void blockingFilter(Sequence &sequence, KeepFunctor keep)
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
ResultType blockingFilteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(pool, std::forward<Sequence>(sequence),
keep, reduce, options);
QFuture<ResultType> future = filteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor>
ResultType blockingFilteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
filteredReduced<ResultType>(std::forward<Sequence>(sequence), keep, reduce, options);
QFuture<ResultType> future = filteredReduced<ResultType>(
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
@ -409,14 +443,15 @@ template <typename ResultType, typename Sequence, typename KeepFunctor, typename
#endif
ResultType blockingFilteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence), keep, reduce,
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
@ -430,77 +465,86 @@ template <typename ResultType, typename Sequence, typename KeepFunctor, typename
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
ResultType blockingFilteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
std::forward<Sequence>(sequence), keep, reduce,
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
#ifndef Q_CLANG_QDOC
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingFilteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(pool, std::forward<Sequence>(sequence),
keep, reduce, options);
QFuture<ResultType> future = filteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingFilteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
filteredReduced<ResultType>(std::forward<Sequence>(sequence), keep, reduce, options);
QFuture<ResultType> future = filteredReduced<ResultType>(
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
ResultType blockingFilteredReduced(QThreadPool *pool,
Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
pool, std::forward<Sequence>(sequence), keep, reduce,
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
template <typename Sequence, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
ResultType blockingFilteredReduced(Sequence &&sequence,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
std::forward<Sequence>(sequence), keep, reduce,
std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
@ -511,25 +555,28 @@ template <typename ResultType, typename Iterator, typename KeepFunctor, typename
ResultType blockingFilteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
filteredReduced<ResultType>(pool, begin, end, keep, reduce, options);
filteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename ResultType, typename Iterator, typename KeepFunctor, typename ReduceFunctor>
ResultType blockingFilteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(begin, end, keep, reduce, options);
QFuture<ResultType> future =
filteredReduced<ResultType>(begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
@ -544,14 +591,14 @@ template <typename ResultType, typename Iterator, typename KeepFunctor, typename
ResultType blockingFilteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
pool, begin, end, keep, reduce,
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
@ -566,114 +613,123 @@ template <typename ResultType, typename Iterator, typename KeepFunctor, typename
#endif
ResultType blockingFilteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options);
begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
#ifndef Q_CLANG_QDOC
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingFilteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
filteredReduced<ResultType>(pool, begin, end, keep, reduce, options);
filteredReduced<ResultType>(pool, begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingFilteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(begin, end, keep, reduce, options);
QFuture<ResultType> future =
filteredReduced<ResultType>(begin, end, std::forward<KeepFunctor>(keep),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
ResultType blockingFilteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end, KeepFunctor keep,
ReduceFunctor reduce,
Iterator end, KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
pool, begin, end, keep, reduce,
pool, begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
template <typename Iterator, typename KeepFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
ResultType blockingFilteredReduced(Iterator begin,
Iterator end,
KeepFunctor keep,
ReduceFunctor reduce,
KeepFunctor &&keep,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = filteredReduced<ResultType>(
begin, end, keep, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options);
begin, end, std::forward<KeepFunctor>(keep), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
#endif
// blocking filtered() on sequences
template <typename Sequence, typename KeepFunctor>
std::decay_t<Sequence> blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor keep)
std::decay_t<Sequence> blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&keep)
{
return blockingFilteredReduced<std::decay_t<Sequence>>(
pool, std::forward<Sequence>(sequence), keep, QtPrivate::PushBackWrapper(),
OrderedReduce);
pool, std::forward<Sequence>(sequence), std::forward<KeepFunctor>(keep),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename Sequence, typename KeepFunctor>
std::decay_t<Sequence> blockingFiltered(Sequence &&sequence, KeepFunctor keep)
std::decay_t<Sequence> blockingFiltered(Sequence &&sequence, KeepFunctor &&keep)
{
return blockingFilteredReduced<std::decay_t<Sequence>>(
QThreadPool::globalInstance(), std::forward<Sequence>(sequence), keep,
QtPrivate::PushBackWrapper(), OrderedReduce);
QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(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)
OutputSequence blockingFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&keep)
{
return blockingFilteredReduced<OutputSequence>(pool, begin, end, keep,
QtPrivate::PushBackWrapper(), OrderedReduce);
return blockingFilteredReduced<OutputSequence>(pool, begin, end,
std::forward<KeepFunctor>(keep),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename OutputSequence, typename Iterator, typename KeepFunctor>
OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)
OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor &&keep)
{
return blockingFilteredReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end, keep,
QtPrivate::PushBackWrapper(), OrderedReduce);
return blockingFilteredReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end,
std::forward<KeepFunctor>(keep),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
} // namespace QtConcurrent

View File

@ -87,12 +87,13 @@ class FilterKernel : public IterateKernel<typename Sequence::const_iterator, voi
Reducer reducer;
public:
FilterKernel(QThreadPool *pool, Sequence &_sequence, KeepFunctor _keep, ReduceFunctor _reduce)
template <typename Keep = KeepFunctor, typename Reduce = ReduceFunctor>
FilterKernel(QThreadPool *pool, Sequence &_sequence, Keep &&_keep, Reduce &&_reduce)
: IterateKernelType(pool, const_cast<const Sequence &>(_sequence).begin(),
const_cast<const Sequence &>(_sequence).end()), reducedResult(),
sequence(_sequence),
keep(_keep),
reduce(_reduce),
keep(std::forward<Keep>(_keep)),
reduce(std::forward<Reduce>(_reduce)),
reducer(pool, OrderedReduce)
{ }
@ -166,23 +167,26 @@ class FilteredReducedKernel : public IterateKernel<Iterator, ReducedResultType>
typedef IterateKernel<Iterator, ReducedResultType> IterateKernelType;
public:
template <typename Keep = KeepFunctor, typename Reduce = ReduceFunctor>
FilteredReducedKernel(QThreadPool *pool,
Iterator begin,
Iterator end,
KeepFunctor _keep,
ReduceFunctor _reduce,
Keep &&_keep,
Reduce &&_reduce,
ReduceOptions reduceOption)
: IterateKernelType(pool, begin, end), reducedResult(), keep(_keep), reduce(_reduce),
: IterateKernelType(pool, begin, end), reducedResult(), keep(std::forward<Keep>(_keep)),
reduce(std::forward<Reduce>(_reduce)),
reducer(pool, reduceOption)
{ }
FilteredReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor _keep,
ReduceFunctor _reduce, ReducedResultType &&initialValue,
template <typename Keep = KeepFunctor, typename Reduce = ReduceFunctor>
FilteredReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, Keep &&_keep,
Reduce &&_reduce, ReducedResultType &&initialValue,
ReduceOptions reduceOption)
: IterateKernelType(pool, begin, end),
reducedResult(std::forward<ReducedResultType>(initialValue)),
keep(_keep),
reduce(_reduce),
keep(std::forward<Keep>(_keep)),
reduce(std::forward<Reduce>(_reduce)),
reducer(pool, reduceOption)
{
}
@ -255,8 +259,9 @@ public:
typedef T ReturnType;
typedef T ResultType;
FilteredEachKernel(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor _keep)
: IterateKernelType(pool, begin, end), keep(_keep)
template <typename Keep = KeepFunctor>
FilteredEachKernel(QThreadPool *pool, Iterator begin, Iterator end, Keep &&_keep)
: IterateKernelType(pool, begin, end), keep(std::forward<Keep>(_keep))
{ }
void start() override
@ -300,43 +305,47 @@ public:
template <typename Iterator, typename KeepFunctor>
inline
ThreadEngineStarter<typename qValueType<Iterator>::value_type>
startFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor functor)
startFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&functor)
{
return startThreadEngine(new FilteredEachKernel<Iterator, KeepFunctor>
(pool, begin, end, functor));
return startThreadEngine(new FilteredEachKernel<Iterator, std::decay_t<KeepFunctor>>
(pool, begin, end, std::forward<KeepFunctor>(functor)));
}
//! [QtConcurrent-3]
template <typename Sequence, typename KeepFunctor>
inline decltype(auto) startFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor functor)
inline decltype(auto) startFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&functor)
{
using DecayedSequence = std::decay_t<Sequence>;
typedef SequenceHolder1<DecayedSequence,
FilteredEachKernel<typename DecayedSequence::const_iterator, KeepFunctor>,
KeepFunctor>
SequenceHolderType;
return startThreadEngine(
new SequenceHolderType(pool, std::forward<Sequence>(sequence), functor));
using DecayedFunctor = std::decay_t<KeepFunctor>;
using SequenceHolderType = SequenceHolder1<DecayedSequence,
FilteredEachKernel<typename DecayedSequence::const_iterator, DecayedFunctor>,
DecayedFunctor>;
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
std::forward<KeepFunctor>(functor)));
}
//! [QtConcurrent-4]
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ReduceOptions options)
{
using DecayedSequence = std::decay_t<Sequence>;
typedef typename DecayedSequence::const_iterator Iterator;
typedef ReduceKernel<ReduceFunctor, ResultType, typename qValueType<Iterator>::value_type >
Reducer;
typedef FilteredReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
FilteredReduceType;
typedef SequenceHolder2<DecayedSequence, FilteredReduceType, MapFunctor, ReduceFunctor>
SequenceHolderType;
using DecayedMapFunctor = std::decay_t<MapFunctor>;
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
using Iterator = typename DecayedSequence::const_iterator;
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType,
typename qValueType<Iterator>::value_type>;
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, DecayedMapFunctor,
DecayedReduceFunctor, Reducer>;
using SequenceHolderType = SequenceHolder2<DecayedSequence, FilteredReduceType,
DecayedMapFunctor, DecayedReduceFunctor>;
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
mapFunctor, reduceFunctor, options));
std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor),
options));
}
@ -345,16 +354,17 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ReduceOptions options)
{
typedef ReduceKernel<ReduceFunctor, ResultType, typename qValueType<Iterator>::value_type>
Reducer;
typedef FilteredReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
FilteredReduceType;
return startThreadEngine(new FilteredReduceType(pool, begin, end, mapFunctor,
reduceFunctor, options));
using Reducer = ReduceKernel<std::decay_t<ReduceFunctor>, ResultType,
typename qValueType<Iterator>::value_type>;
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
std::decay_t<ReduceFunctor>, Reducer>;
return startThreadEngine(
new FilteredReduceType(pool, begin, end, std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor), options));
}
// Repeat the two functions above, but now with an initial value!
@ -362,22 +372,25 @@ inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ResultType &&initialValue,
ReduceOptions options)
{
using DecayedSequence = std::decay_t<Sequence>;
typedef typename DecayedSequence::const_iterator Iterator;
typedef ReduceKernel<ReduceFunctor, ResultType, typename qValueType<Iterator>::value_type >
Reducer;
typedef FilteredReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
FilteredReduceType;
typedef SequenceHolder2<DecayedSequence, FilteredReduceType, MapFunctor, ReduceFunctor>
SequenceHolderType;
return startThreadEngine(
new SequenceHolderType(pool, std::forward<Sequence>(sequence), mapFunctor,
reduceFunctor, std::forward<ResultType>(initialValue), options));
using DecayedMapFunctor = std::decay_t<MapFunctor>;
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
using Iterator = typename DecayedSequence::const_iterator;
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType,
typename qValueType<Iterator>::value_type>;
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, DecayedMapFunctor,
DecayedReduceFunctor, Reducer>;
using SequenceHolderType = SequenceHolder2<DecayedSequence, FilteredReduceType,
DecayedMapFunctor, DecayedReduceFunctor>;
return startThreadEngine(new SequenceHolderType(
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor), std::forward<ResultType>(initialValue),
options));
}
//! [QtConcurrent-7]
@ -385,17 +398,19 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
inline ThreadEngineStarter<ResultType> startFilteredReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ResultType &&initialValue,
ReduceOptions options)
{
typedef ReduceKernel<ReduceFunctor, ResultType, typename qValueType<Iterator>::value_type>
Reducer;
typedef FilteredReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
FilteredReduceType;
return startThreadEngine(new FilteredReduceType(pool, begin, end, mapFunctor, reduceFunctor,
std::forward<ResultType>(initialValue), options));
using Reducer = ReduceKernel<std::decay_t<ReduceFunctor>, ResultType,
typename qValueType<Iterator>::value_type>;
using FilteredReduceType = FilteredReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
std::decay_t<ReduceFunctor>, Reducer>;
return startThreadEngine(
new FilteredReduceType(pool, begin, end, std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor),
std::forward<ResultType>(initialValue), options));
}

View File

@ -94,37 +94,37 @@
*/
/*!
\fn [qtconcurrentmapkernel-1] ThreadEngineStarter<void> QtConcurrent::startMap(Iterator begin, Iterator end, Functor functor)
\fn [qtconcurrentmapkernel-1] ThreadEngineStarter<void> QtConcurrent::startMap(Iterator begin, Iterator end, Functor &&functor)
\internal
*/
/*!
\fn [qtconcurrentmapkernel-2] ThreadEngineStarter<T> QtConcurrent::startMapped(Iterator begin, Iterator end, Functor functor)
\fn [qtconcurrentmapkernel-2] ThreadEngineStarter<T> QtConcurrent::startMapped(Iterator begin, Iterator end, Functor &&functor)
\internal
*/
/*!
\fn [qtconcurrentmapkernel-3] ThreadEngineStarter<T> QtConcurrent::startMapped(Sequence &&sequence, Functor functor)
\fn [qtconcurrentmapkernel-3] ThreadEngineStarter<T> QtConcurrent::startMapped(Sequence &&sequence, Functor &&functor)
\internal
*/
/*!
\fn [qtconcurrentmapkernel-4] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Sequence && sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
\fn [qtconcurrentmapkernel-4] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Sequence &&sequence, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ReduceOptions options)
\internal
*/
/*!
\fn [qtconcurrentmapkernel-5] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
\fn [qtconcurrentmapkernel-5] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ReduceOptions options)
\internal
*/
/*!
\fn [qtconcurrentmapkernel-6] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Sequence && sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ResultType &&initialValue, ReduceOptions options)
\fn [qtconcurrentmapkernel-6] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Sequence &&sequence, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ResultType &&initialValue, ReduceOptions options)
\internal
*/
/*!
\fn [qtconcurrentmapkernel-7] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ResultType &&initialValue, ReduceOptions options)
\fn [qtconcurrentmapkernel-7] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunctor, ReduceFunctor &&reduceFunctor, ResultType &&initialValue, ReduceOptions options)
\internal
*/
@ -320,7 +320,7 @@
*/
/*!
\fn template <typename Sequence, typename MapFunctor> QFuture<void> QtConcurrent::map(QThreadPool *pool, Sequence &&sequence, MapFunctor function)
\fn template <typename Sequence, typename MapFunctor> QFuture<void> QtConcurrent::map(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence.
All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
@ -331,7 +331,7 @@
*/
/*!
\fn template <typename Sequence, typename MapFunctor> QFuture<void> QtConcurrent::map(Sequence &&sequence, MapFunctor function)
\fn template <typename Sequence, typename MapFunctor> QFuture<void> QtConcurrent::map(Sequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence. The \a function takes
a reference to the item, so that any modifications done to the item
@ -341,7 +341,7 @@
*/
/*!
\fn template <typename Iterator, typename MapFunctor> QFuture<void> QtConcurrent::map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Iterator, typename MapFunctor> QFuture<void> QtConcurrent::map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end.
All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
@ -352,7 +352,7 @@
*/
/*!
\fn template <typename Iterator, typename MapFunctor> QFuture<void> QtConcurrent::map(Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Iterator, typename MapFunctor> QFuture<void> QtConcurrent::map(Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end. The
\a function takes a reference to the item, so that any modifications
@ -362,7 +362,7 @@
*/
/*!
\fn template <typename Sequence, typename MapFunctor> QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> QtConcurrent::mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor function)
\fn template <typename Sequence, typename MapFunctor> QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> QtConcurrent::mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence and returns a future
with each mapped item as a result. All calls to \a function are invoked from the
@ -373,7 +373,7 @@
*/
/*!
\fn template <typename Sequence, typename MapFunctor> QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> QtConcurrent::mapped(Sequence &&sequence, MapFunctor function)
\fn template <typename Sequence, typename MapFunctor> QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> QtConcurrent::mapped(Sequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence and returns a future
with each mapped item as a result. You can use QFuture::const_iterator or
@ -383,7 +383,7 @@
*/
/*!
\fn template <typename Iterator, typename MapFunctor> QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> QtConcurrent::mapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Iterator, typename MapFunctor> QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> QtConcurrent::mapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end and returns a
future with each mapped item as a result. All calls to \a function are invoked from the
@ -394,7 +394,7 @@
*/
/*!
\fn template <typename Iterator, typename MapFunctor> QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> QtConcurrent::mapped(Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Iterator, typename MapFunctor> QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> QtConcurrent::mapped(Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end and returns a
future with each mapped item as a result. You can use
@ -404,7 +404,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -418,7 +418,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence. The return value of
each \a mapFunction is passed to \a reduceFunction.
@ -431,7 +431,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -448,7 +448,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence. The return value of
each \a mapFunction is passed to \a reduceFunction.
@ -464,7 +464,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -480,7 +480,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end. The return
value of each \a mapFunction is passed to \a reduceFunction.
@ -495,7 +495,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -514,7 +514,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> QFuture<ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, &&ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end. The return
value of each \a mapFunction is passed to \a reduceFunction.
@ -532,7 +532,7 @@
*/
/*!
\fn template <typename Sequence, typename MapFunctor> void QtConcurrent::blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor function)
\fn template <typename Sequence, typename MapFunctor> void QtConcurrent::blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence.
All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
@ -545,7 +545,7 @@
*/
/*!
\fn template <typename Sequence, typename MapFunctor> void QtConcurrent::blockingMap(Sequence &&sequence, MapFunctor function)
\fn template <typename Sequence, typename MapFunctor> void QtConcurrent::blockingMap(Sequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence. The \a function takes
a reference to the item, so that any modifications done to the item
@ -557,7 +557,7 @@
*/
/*!
\fn template <typename Iterator, typename MapFunctor> void QtConcurrent::blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Iterator, typename MapFunctor> void QtConcurrent::blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end.
All calls to \a function are invoked from the threads taken from the QThreadPool \a pool.
@ -571,7 +571,7 @@
*/
/*!
\fn template <typename Iterator, typename MapFunctor> void QtConcurrent::blockingMap(Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Iterator, typename MapFunctor> void QtConcurrent::blockingMap(Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end. The
\a function takes a reference to the item, so that any modifications
@ -584,7 +584,7 @@
*/
/*!
\fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor function)
\fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence and returns an OutputSequence containing
the results. All calls to \a function are invoked from the threads taken from the QThreadPool
@ -596,7 +596,7 @@
*/
/*!
\fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(InputSequence &&sequence, MapFunctor function)
\fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(InputSequence &&sequence, MapFunctor &&function)
Calls \a function once for each item in \a sequence and returns an OutputSequence containing
the results. The type of the results will match the type returned by the MapFunctor.
@ -607,7 +607,7 @@
*/
/*!
\fn template <typename Sequence, typename Iterator, typename MapFunctor> Sequence QtConcurrent::blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Sequence, typename Iterator, typename MapFunctor> Sequence QtConcurrent::blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end and returns a
container with the results. All calls to \a function are invoked from the threads
@ -625,7 +625,7 @@
*/
/*!
\fn template <typename Sequence, typename Iterator, typename MapFunctor> Sequence QtConcurrent::blockingMapped(Iterator begin, Iterator end, MapFunctor function)
\fn template <typename Sequence, typename Iterator, typename MapFunctor> Sequence QtConcurrent::blockingMapped(Iterator begin, Iterator end, MapFunctor &&function)
Calls \a function once for each item from \a begin to \a end and returns a
container with the results. You can specify the type of container as the a template
@ -642,7 +642,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -658,7 +658,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence. The return value of
each \a mapFunction is passed to \a reduceFunction.
@ -673,7 +673,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -692,7 +692,7 @@
*/
/*!
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item in \a sequence. The return value of
each \a mapFunction is passed to \a reduceFunction.
@ -710,7 +710,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -727,7 +727,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end. The return
value of each \a mapFunction is passed to \a reduceFunction.
@ -743,7 +743,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end.
All calls to \a mapFunction are invoked from the threads taken from the QThreadPool \a pool.
@ -763,7 +763,7 @@
*/
/*!
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
\fn template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor, typename InitialValueType> ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions)
Calls \a mapFunction once for each item from \a begin to \a end. The return
value of each \a mapFunction is passed to \a reduceFunction.

View File

@ -57,52 +57,55 @@ namespace QtConcurrent {
// map() on sequences
template <typename Sequence, typename MapFunctor>
QFuture<void> map(QThreadPool *pool, Sequence &&sequence, MapFunctor map)
QFuture<void> map(QThreadPool *pool, Sequence &&sequence, MapFunctor &&map)
{
return startMap(pool, sequence.begin(), sequence.end(), map);
return startMap(pool, sequence.begin(), sequence.end(), std::forward<MapFunctor>(map));
}
template <typename Sequence, typename MapFunctor>
QFuture<void> map(Sequence &&sequence, MapFunctor map)
QFuture<void> map(Sequence &&sequence, MapFunctor &&map)
{
return startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(), map);
return startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(),
std::forward<MapFunctor>(map));
}
// map() on iterators
template <typename Iterator, typename MapFunctor>
QFuture<void> map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor map)
QFuture<void> map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
{
return startMap(pool, begin, end, map);
return startMap(pool, begin, end, std::forward<MapFunctor>(map));
}
template <typename Iterator, typename MapFunctor>
QFuture<void> map(Iterator begin, Iterator end, MapFunctor map)
QFuture<void> map(Iterator begin, Iterator end, MapFunctor &&map)
{
return startMap(QThreadPool::globalInstance(), begin, end, map);
return startMap(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map));
}
// mappedReduced() for sequences.
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, std::forward<Sequence>(sequence), map, reduce, options);
(pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
}
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
QFuture<ResultType> mappedReduced(Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce, options);
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce), options);
}
#ifdef Q_CLANG_QDOC
@ -115,14 +118,15 @@ template <typename ResultType, typename Sequence, typename MapFunctor, typename
#endif
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>(
pool, std::forward<Sequence>(sequence), map, reduce,
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
#ifdef Q_CLANG_QDOC
@ -134,41 +138,45 @@ template <typename ResultType, typename Sequence, typename MapFunctor, typename
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
QFuture<ResultType> mappedReduced(Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce,
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(pool, std::forward<Sequence>(sequence), map, reduce, options);
(pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
}
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
QFuture<ResultType> mappedReduced(
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> mappedReduced(Sequence &&sequence,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce, options);
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce), options);
}
#ifdef Q_CLANG_QDOC
@ -176,20 +184,22 @@ template <typename Sequence, typename MapFunctor, typename ReduceFunctor, typena
typename InitialValueType>
#else
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>(
pool, std::forward<Sequence>(sequence), map, reduce,
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
@ -198,19 +208,21 @@ template <typename Sequence, typename MapFunctor, typename ReduceFunctor, typena
typename InitialValueType>
#else
template <typename Sequence, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
QFuture<ResultType> mappedReduced(Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Sequence, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map, reduce,
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
@ -219,25 +231,27 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, options);
(pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
options);
}
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
QFuture<ResultType> mappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce, options);
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
}
#ifdef Q_CLANG_QDOC
@ -251,14 +265,14 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce,
(pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
@ -272,42 +286,46 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
#endif
QFuture<ResultType> mappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce,
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, options);
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>(
pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
options);
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType = typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
QFuture<ResultType> mappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce, options);
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
}
#ifdef Q_CLANG_QDOC
@ -315,43 +333,46 @@ template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typena
typename InitialValueType>
#else
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
QFuture<ResultType> mappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options);
(pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
#ifdef Q_CLANG_QDOC
template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typename ResultType,
typename InitialValueType>
#else
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>
template<typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
QFuture<ResultType> mappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
return startMappedReduced<QtPrivate::MapResultType<Iterator, MapFunctor>, ResultType>
(QThreadPool::globalInstance(), begin, end, map, reduce,
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
}
@ -360,19 +381,20 @@ template <typename Sequence, typename MapFunctor>
QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> mapped(
QThreadPool *pool,
Sequence &&sequence,
MapFunctor map)
MapFunctor &&map)
{
return startMapped<QtPrivate::MapResultType<Sequence, MapFunctor>>(
pool, std::forward<Sequence>(sequence), map);
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map));
}
template <typename Sequence, typename MapFunctor>
QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> mapped(
Sequence &&sequence,
MapFunctor map)
MapFunctor &&map)
{
return startMapped<QtPrivate::MapResultType<Sequence, MapFunctor>>
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence), map);
(QThreadPool::globalInstance(), std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map));
}
// mapped() for iterator ranges.
@ -381,48 +403,52 @@ QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> mapped(
QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map)
MapFunctor &&map)
{
return startMapped<QtPrivate::MapResultType<Iterator, MapFunctor>>(pool, begin, end, map);
return startMapped<QtPrivate::MapResultType<Iterator, MapFunctor>>(
pool, begin, end, std::forward<MapFunctor>(map));
}
template <typename Iterator, typename MapFunctor>
QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> mapped(
Iterator begin,
Iterator end,
MapFunctor map)
MapFunctor &&map)
{
return startMapped<QtPrivate::MapResultType<Iterator, MapFunctor>>
(QThreadPool::globalInstance(), begin, end, map);
(QThreadPool::globalInstance(), begin, end, std::forward<MapFunctor>(map));
}
// blockingMap() for sequences
template <typename Sequence, typename MapFunctor>
void blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor map)
{
QFuture<void> future = startMap(pool, sequence.begin(), sequence.end(), map);
QFuture<void> future =
startMap(pool, sequence.begin(), sequence.end(), std::forward<MapFunctor>(map));
future.waitForFinished();
}
template <typename Sequence, typename MapFunctor>
void blockingMap(Sequence &&sequence, MapFunctor map)
void blockingMap(Sequence &&sequence, MapFunctor &&map)
{
QFuture<void> future = startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(), map);
QFuture<void> future = startMap(QThreadPool::globalInstance(), sequence.begin(), sequence.end(),
std::forward<MapFunctor>(map));
future.waitForFinished();
}
// blockingMap() for iterator ranges
template <typename Iterator, typename MapFunctor>
void blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor map)
void blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
{
QFuture<void> future = startMap(pool, begin, end, map);
future.waitForFinished();
}
template <typename Iterator, typename MapFunctor>
void blockingMap(Iterator begin, Iterator end, MapFunctor map)
void blockingMap(Iterator begin, Iterator end, MapFunctor &&map)
{
QFuture<void> future = startMap(QThreadPool::globalInstance(), begin, end, map);
QFuture<void> future = startMap(QThreadPool::globalInstance(), begin, end,
std::forward<MapFunctor>(map));
future.waitForFinished();
}
@ -430,25 +456,29 @@ void blockingMap(Iterator begin, Iterator end, MapFunctor map)
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
ResultType blockingMappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence), map, reduce, options);
mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor>
ResultType blockingMappedReduced(Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
mappedReduced<ResultType>(std::forward<Sequence>(sequence), map, reduce, options);
mappedReduced<ResultType>(std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
@ -462,14 +492,15 @@ template <typename ResultType, typename Sequence, typename MapFunctor, typename
#endif
ResultType blockingMappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
pool, std::forward<Sequence>(sequence), map, reduce,
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
@ -483,42 +514,49 @@ template <typename ResultType, typename Sequence, typename MapFunctor, typename
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
ResultType blockingMappedReduced(Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
std::forward<Sequence>(sequence), map, reduce,
std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingMappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence), map, reduce, options);
mappedReduced<ResultType>(pool, std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingMappedReduced(Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future =
mappedReduced<ResultType>(std::forward<Sequence>(sequence), map, reduce, options);
mappedReduced<ResultType>(std::forward<Sequence>(sequence),
std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
@ -527,20 +565,22 @@ template <typename MapFunctor, typename ReduceFunctor, typename Sequence, typena
typename InitialValueType>
#else
template <typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
ResultType blockingMappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
pool, std::forward<Sequence>(sequence), map, reduce,
pool, std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
@ -549,20 +589,22 @@ ResultType blockingMappedReduced(QThreadPool *pool,
template <typename MapFunctor, typename ReduceFunctor, typename Sequence, typename ResultType,
typename InitialValueType>
#else
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>
template<typename MapFunctor, typename ReduceFunctor, typename Sequence,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
ResultType blockingMappedReduced(Sequence &&sequence,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
std::forward<Sequence>(sequence), map, reduce,
std::forward<Sequence>(sequence), std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
@ -572,24 +614,28 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
ResultType blockingMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(pool, begin, end, map, reduce, options);
QFuture<ResultType> future =
mappedReduced<ResultType>(pool, begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename ResultType, typename Iterator, typename MapFunctor, typename ReduceFunctor>
ResultType blockingMappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(begin, end, map, reduce, options);
QFuture<ResultType> future =
mappedReduced<ResultType>(begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
@ -604,14 +650,15 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
ResultType blockingMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)),
options);
return future.takeResult();
}
@ -626,42 +673,49 @@ template <typename ResultType, typename Iterator, typename MapFunctor, typename
#endif
ResultType blockingMappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)),
options);
return future.takeResult();
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(pool, begin, end, map, reduce, options);
QFuture<ResultType> future =
mappedReduced<ResultType>(pool, begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType>
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType>
ResultType blockingMappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(begin, end, map, reduce, options);
QFuture<ResultType> future =
mappedReduced<ResultType>(begin, end, std::forward<MapFunctor>(map),
std::forward<ReduceFunctor>(reduce), options);
return future.takeResult();
}
@ -670,22 +724,23 @@ template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typena
typename InitialValueType>
#else
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
ResultType blockingMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
pool, begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options);
pool, begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
@ -694,88 +749,94 @@ template <typename Iterator, typename MapFunctor, typename ReduceFunctor, typena
typename InitialValueType>
#else
template <typename Iterator, typename MapFunctor, typename ReduceFunctor,
typename ResultType = typename QtPrivate::ReduceResultType<ReduceFunctor>::ResultType,
typename ResultType =
typename QtPrivate::ReduceResultType<std::decay_t<ReduceFunctor>>::ResultType,
typename InitialValueType,
std::enable_if_t<std::is_convertible_v<InitialValueType, ResultType>, int> = 0>
#endif
ResultType blockingMappedReduced(Iterator begin,
Iterator end,
MapFunctor map,
ReduceFunctor reduce,
MapFunctor &&map,
ReduceFunctor &&reduce,
InitialValueType &&initialValue,
ReduceOptions options = ReduceOptions(UnorderedReduce
| SequentialReduce))
{
QFuture<ResultType> future = mappedReduced<ResultType>(
begin, end, map, reduce, ResultType(std::forward<InitialValueType>(initialValue)),
options);
begin, end, std::forward<MapFunctor>(map), std::forward<ReduceFunctor>(reduce),
ResultType(std::forward<InitialValueType>(initialValue)), options);
return future.takeResult();
}
// mapped() for sequences with a different putput sequence type.
template <typename OutputSequence, typename InputSequence, typename MapFunctor>
OutputSequence blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor map)
OutputSequence blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&map)
{
return blockingMappedReduced<OutputSequence>(pool, std::forward<InputSequence>(sequence), map,
QtPrivate::PushBackWrapper(), OrderedReduce);
return blockingMappedReduced<OutputSequence>(pool, std::forward<InputSequence>(sequence),
std::forward<MapFunctor>(map),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename OutputSequence, typename InputSequence, typename MapFunctor>
OutputSequence blockingMapped(InputSequence &&sequence, MapFunctor map)
OutputSequence blockingMapped(InputSequence &&sequence, MapFunctor &&map)
{
return blockingMappedReduced<OutputSequence>(QThreadPool::globalInstance(),
std::forward<InputSequence>(sequence), map,
return blockingMappedReduced<OutputSequence>(
QThreadPool::globalInstance(), std::forward<InputSequence>(sequence),
std::forward<MapFunctor>(map), QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename MapFunctor, typename InputSequence>
auto blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&map)
{
using OutputSequence = typename QtPrivate::MapSequenceResultType<std::decay_t<InputSequence>,
MapFunctor>::ResultType;
return blockingMappedReduced<OutputSequence>(pool, std::forward<InputSequence>(sequence),
std::forward<MapFunctor>(map),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename MapFunctor, typename InputSequence>
auto blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor map)
{
using OutputSequence = typename QtPrivate::MapSequenceResultType<std::decay_t<InputSequence>,
MapFunctor>::ResultType;
return blockingMappedReduced<OutputSequence>(pool, std::forward<InputSequence>(sequence), map,
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename MapFunctor, typename InputSequence>
auto blockingMapped(InputSequence &&sequence, MapFunctor map)
auto blockingMapped(InputSequence &&sequence, MapFunctor &&map)
{
using OutputSequence = typename QtPrivate::MapSequenceResultType<std::decay_t<InputSequence>,
MapFunctor>::ResultType;
return blockingMappedReduced<OutputSequence>(QThreadPool::globalInstance(),
std::forward<InputSequence>(sequence), map,
std::forward<InputSequence>(sequence),
std::forward<MapFunctor>(map),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
// mapped() for iterator ranges
template <typename Sequence, typename Iterator, typename MapFunctor>
Sequence blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor map)
Sequence blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
{
return blockingMappedReduced<Sequence>(pool, begin, end, map,
return blockingMappedReduced<Sequence>(pool, begin, end, std::forward<MapFunctor>(map),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename Sequence, typename Iterator, typename MapFunctor>
Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor map)
Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor &&map)
{
return blockingMappedReduced<Sequence>(QThreadPool::globalInstance(), begin, end, map,
return blockingMappedReduced<Sequence>(QThreadPool::globalInstance(), begin, end,
std::forward<MapFunctor>(map),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename Iterator, typename MapFunctor>
auto blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&map)
{
using OutputSequence = QtPrivate::MapResultType<Iterator, MapFunctor>;
return blockingMappedReduced<OutputSequence>(pool, begin, end, std::forward<MapFunctor>(map),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename Iterator, typename MapFunctor>
auto blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor map)
auto blockingMapped(Iterator begin, Iterator end, MapFunctor &&map)
{
using OutputSequence = QtPrivate::MapResultType<Iterator, MapFunctor>;
return blockingMappedReduced<OutputSequence>(pool, begin, end, map,
QtPrivate::PushBackWrapper(), OrderedReduce);
}
template <typename Iterator, typename MapFunctor>
auto blockingMapped(Iterator begin, Iterator end, MapFunctor map)
{
using OutputSequence = QtPrivate::MapResultType<Iterator, MapFunctor>;
return blockingMappedReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end, map,
QtPrivate::PushBackWrapper(), OrderedReduce);
return blockingMappedReduced<OutputSequence>(QThreadPool::globalInstance(), begin, end,
std::forward<MapFunctor>(map),
QtPrivate::PushBackWrapper(), OrderedReduce);
}
} // namespace QtConcurrent

View File

@ -60,8 +60,9 @@ class MapKernel : public IterateKernel<Iterator, void>
MapFunctor map;
public:
typedef void ReturnType;
MapKernel(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor _map)
: IterateKernel<Iterator, void>(pool, begin, end), map(_map)
template <typename F = MapFunctor>
MapKernel(QThreadPool *pool, Iterator begin, Iterator end, F &&_map)
: IterateKernel<Iterator, void>(pool, begin, end), map(std::forward<F>(_map))
{ }
bool runIteration(Iterator it, int, void *) override
@ -100,19 +101,23 @@ class MappedReducedKernel : public IterateKernel<Iterator, ReducedResultType>
public:
typedef ReducedResultType ReturnType;
MappedReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor _map,
ReduceFunctor _reduce, ReduceOptions reduceOptions)
template <typename F1 = MapFunctor, typename F2 = ReduceFunctor>
MappedReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, F1 &&_map,
F2 &&_reduce, ReduceOptions reduceOptions)
: IterateKernel<Iterator, ReducedResultType>(pool, begin, end), reducedResult(),
map(_map), reduce(_reduce), reducer(pool, reduceOptions)
map(std::forward<F1>(_map)), reduce(std::forward<F2>(_reduce)),
reducer(pool, reduceOptions)
{ }
MappedReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor _map,
ReduceFunctor _reduce, ReducedResultType &&initialValue,
template <typename F1 = MapFunctor, typename F2 = ReduceFunctor>
MappedReducedKernel(QThreadPool *pool, Iterator begin, Iterator end, F1 &&_map,
F2 &&_reduce, ReducedResultType &&initialValue,
ReduceOptions reduceOptions)
: IterateKernel<Iterator, ReducedResultType>(pool, begin, end),
reducedResult(std::forward<ReducedResultType>(initialValue)),
map(_map),
reduce(_reduce),
map(std::forward<F1>(_map)),
reduce(std::forward<F2>(_reduce)),
reducer(pool, reduceOptions)
{
}
@ -175,8 +180,10 @@ class MappedEachKernel : public IterateKernel<Iterator, QtPrivate::MapResultType
using T = QtPrivate::MapResultType<Iterator, MapFunctor>;
public:
MappedEachKernel(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor _map)
: IterateKernel<Iterator, T>(pool, begin, end), map(_map) { }
template <typename F = MapFunctor>
MappedEachKernel(QThreadPool *pool, Iterator begin, Iterator end, F &&_map)
: IterateKernel<Iterator, T>(pool, begin, end), map(std::forward<F>(_map))
{ }
bool runIteration(Iterator it, int, T *result) override
{
@ -201,17 +208,19 @@ public:
//! [qtconcurrentmapkernel-1]
template <typename Iterator, typename Functor>
inline ThreadEngineStarter<void> startMap(QThreadPool *pool, Iterator begin,
Iterator end, Functor functor)
Iterator end, Functor &&functor)
{
return startThreadEngine(new MapKernel<Iterator, Functor>(pool, begin, end, functor));
return startThreadEngine(new MapKernel<Iterator, std::decay_t<Functor>>(
pool, begin, end, std::forward<Functor>(functor)));
}
//! [qtconcurrentmapkernel-2]
template <typename T, typename Iterator, typename Functor>
inline ThreadEngineStarter<T> startMapped(QThreadPool *pool, Iterator begin,
Iterator end, Functor functor)
Iterator end, Functor &&functor)
{
return startThreadEngine(new MappedEachKernel<Iterator, Functor>(pool, begin, end, functor));
return startThreadEngine(new MappedEachKernel<Iterator, std::decay_t<Functor>>(
pool, begin, end, std::forward<Functor>(functor)));
}
/*
@ -221,14 +230,10 @@ inline ThreadEngineStarter<T> startMapped(QThreadPool *pool, Iterator begin,
template <typename Sequence, typename Base, typename Functor>
struct SequenceHolder1 : private QtPrivate::SequenceHolder<Sequence>, public Base
{
SequenceHolder1(QThreadPool *pool, Sequence &&_sequence, Functor functor)
: QtPrivate::SequenceHolder<Sequence>(std::move(_sequence)),
Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor)
{ }
SequenceHolder1(QThreadPool *pool, const Sequence &_sequence, Functor functor)
: QtPrivate::SequenceHolder<Sequence>(_sequence),
Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor)
template<typename S = Sequence, typename F = Functor>
SequenceHolder1(QThreadPool *pool, S &&_sequence, F &&functor)
: QtPrivate::SequenceHolder<Sequence>(std::forward<S>(_sequence)),
Base(pool, this->sequence.cbegin(), this->sequence.cend(), std::forward<F>(functor))
{ }
void finish() override
@ -243,16 +248,17 @@ struct SequenceHolder1 : private QtPrivate::SequenceHolder<Sequence>, public Bas
//! [qtconcurrentmapkernel-3]
template <typename T, typename Sequence, typename Functor>
inline ThreadEngineStarter<T> startMapped(QThreadPool *pool, Sequence &&sequence,
Functor functor)
Functor &&functor)
{
using DecayedSequence = std::decay_t<Sequence>;
typedef SequenceHolder1<DecayedSequence,
MappedEachKernel<typename DecayedSequence::const_iterator, Functor>,
Functor>
SequenceHolderType;
using DecayedFunctor = std::decay_t<Functor>;
using SequenceHolderType = SequenceHolder1<
DecayedSequence,
MappedEachKernel<typename DecayedSequence::const_iterator, DecayedFunctor>,
DecayedFunctor>;
return startThreadEngine(
new SequenceHolderType(pool, std::forward<Sequence>(sequence), functor));
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
std::forward<Functor>(functor)));
}
//! [qtconcurrentmapkernel-4]
@ -260,19 +266,23 @@ template <typename IntermediateType, typename ResultType, typename Sequence, typ
typename ReduceFunctor>
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ReduceOptions options)
{
using DecayedSequence = std::decay_t<Sequence>;
typedef typename DecayedSequence::const_iterator Iterator;
typedef ReduceKernel<ReduceFunctor, ResultType, IntermediateType> Reducer;
typedef MappedReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
MappedReduceType;
typedef SequenceHolder2<DecayedSequence, MappedReduceType, MapFunctor, ReduceFunctor>
SequenceHolderType;
using DecayedMapFunctor = std::decay_t<MapFunctor>;
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
using Iterator = typename DecayedSequence::const_iterator;
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType, IntermediateType>;
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, DecayedMapFunctor,
DecayedReduceFunctor, Reducer>;
using SequenceHolderType = SequenceHolder2<DecayedSequence, MappedReduceType, DecayedMapFunctor,
DecayedReduceFunctor>;
return startThreadEngine(new SequenceHolderType(pool, std::forward<Sequence>(sequence),
mapFunctor, reduceFunctor, options));
std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor),
options));
}
//! [qtconcurrentmapkernel-5]
@ -281,14 +291,17 @@ template <typename IntermediateType, typename ResultType, typename Iterator, typ
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ReduceOptions options)
{
typedef ReduceKernel<ReduceFunctor, ResultType, IntermediateType> Reducer;
typedef MappedReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
MappedReduceType;
return startThreadEngine(new MappedReduceType(pool, begin, end, mapFunctor, reduceFunctor,
using Reducer =
ReduceKernel<std::decay_t<ReduceFunctor>, std::decay_t<ResultType>, IntermediateType>;
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
std::decay_t<ReduceFunctor>, Reducer>;
return startThreadEngine(new MappedReduceType(pool, begin, end,
std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor),
options));
}
@ -297,21 +310,25 @@ template <typename IntermediateType, typename ResultType, typename Sequence, typ
typename ReduceFunctor>
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
Sequence &&sequence,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ResultType &&initialValue,
ReduceOptions options)
{
using DecayedSequence = std::decay_t<Sequence>;
typedef typename DecayedSequence::const_iterator Iterator;
typedef ReduceKernel<ReduceFunctor, ResultType, IntermediateType> Reducer;
typedef MappedReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
MappedReduceType;
typedef SequenceHolder2<DecayedSequence, MappedReduceType, MapFunctor, ReduceFunctor>
SequenceHolderType;
using DecayedMapFunctor = std::decay_t<MapFunctor>;
using DecayedReduceFunctor = std::decay_t<ReduceFunctor>;
using Iterator = typename DecayedSequence::const_iterator;
using Reducer = ReduceKernel<DecayedReduceFunctor, ResultType, IntermediateType>;
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, DecayedMapFunctor,
DecayedReduceFunctor, Reducer>;
using SequenceHolderType = SequenceHolder2<DecayedSequence, MappedReduceType, DecayedMapFunctor,
DecayedReduceFunctor>;
return startThreadEngine(
new SequenceHolderType(pool, std::forward<Sequence>(sequence), mapFunctor,
reduceFunctor, std::forward<ResultType>(initialValue), options));
new SequenceHolderType(pool, std::forward<Sequence>(sequence),
std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor),
std::forward<ResultType>(initialValue), options));
}
//! [qtconcurrentmapkernel-7]
@ -320,15 +337,17 @@ template <typename IntermediateType, typename ResultType, typename Iterator, typ
inline ThreadEngineStarter<ResultType> startMappedReduced(QThreadPool *pool,
Iterator begin,
Iterator end,
MapFunctor mapFunctor,
ReduceFunctor reduceFunctor,
MapFunctor &&mapFunctor,
ReduceFunctor &&reduceFunctor,
ResultType &&initialValue,
ReduceOptions options)
{
typedef ReduceKernel<ReduceFunctor, ResultType, IntermediateType> Reducer;
typedef MappedReducedKernel<ResultType, Iterator, MapFunctor, ReduceFunctor, Reducer>
MappedReduceType;
return startThreadEngine(new MappedReduceType(pool, begin, end, mapFunctor, reduceFunctor,
using Reducer = ReduceKernel<std::decay_t<ReduceFunctor>, ResultType, IntermediateType>;
using MappedReduceType = MappedReducedKernel<ResultType, Iterator, std::decay_t<MapFunctor>,
std::decay_t<ReduceFunctor>, Reducer>;
return startThreadEngine(new MappedReduceType(pool, begin, end,
std::forward<MapFunctor>(mapFunctor),
std::forward<ReduceFunctor>(reduceFunctor),
std::forward<ResultType>(initialValue), options));
}

View File

@ -225,33 +225,21 @@ public:
template <typename Sequence, typename Base, typename Functor1, typename Functor2>
struct SequenceHolder2 : private QtPrivate::SequenceHolder<Sequence>, public Base
{
SequenceHolder2(QThreadPool *pool, const Sequence &_sequence, Functor1 functor1,
Functor2 functor2, ReduceOptions reduceOptions)
: QtPrivate::SequenceHolder<Sequence>(_sequence),
Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor1, functor2,
reduceOptions)
{ }
SequenceHolder2(QThreadPool *pool, Sequence &&_sequence, Functor1 functor1, Functor2 functor2,
template<typename S = Sequence, typename F1 = Functor1, typename F2 = Functor2>
SequenceHolder2(QThreadPool *pool, S &&_sequence, F1 &&functor1, F2 &&functor2,
ReduceOptions reduceOptions)
: QtPrivate::SequenceHolder<Sequence>(std::move(_sequence)),
Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor1, functor2,
reduceOptions)
: QtPrivate::SequenceHolder<Sequence>(std::forward<S>(_sequence)),
Base(pool, this->sequence.cbegin(), this->sequence.cend(),
std::forward<F1>(functor1), std::forward<F2>(functor2), reduceOptions)
{ }
template<typename InitialValueType>
SequenceHolder2(QThreadPool *pool, const Sequence &_sequence, Functor1 functor1,
Functor2 functor2, InitialValueType &&initialValue, ReduceOptions reduceOptions)
: QtPrivate::SequenceHolder<Sequence>(_sequence),
Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor1, functor2,
std::forward<InitialValueType>(initialValue), reduceOptions)
{ }
template<typename InitialValueType>
SequenceHolder2(QThreadPool *pool, Sequence &&_sequence, Functor1 functor1, Functor2 functor2,
template<typename InitialValueType, typename S = Sequence,
typename F1 = Functor1, typename F2 = Functor2>
SequenceHolder2(QThreadPool *pool, S &&_sequence, F1 &&functor1, F2 &&functor2,
InitialValueType &&initialValue, ReduceOptions reduceOptions)
: QtPrivate::SequenceHolder<Sequence>(std::move(_sequence)),
Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor1, functor2,
: QtPrivate::SequenceHolder<Sequence>(std::forward<S>(_sequence)),
Base(pool, this->sequence.cbegin(), this->sequence.cend(),
std::forward<F1>(functor1), std::forward<F2>(functor2),
std::forward<InitialValueType>(initialValue), reduceOptions)
{ }

View File

@ -39,13 +39,17 @@ class tst_QtConcurrentFilter : public QObject
private slots:
void filter();
void filterThreadPool();
void filterWithMoveOnlyCallable();
void filtered();
void filteredThreadPool();
void filteredWithMoveOnlyCallable();
void filteredReduced();
void filteredReducedThreadPool();
void filteredReducedWithMoveOnlyCallables();
void filteredReducedDifferentType();
void filteredReducedInitialValue();
void filteredReducedInitialValueThreadPool();
void filteredReducedInitialValueWithMoveOnlyCallables();
void filteredReducedDifferentTypeInitialValue();
void resultAt();
void incrementalResults();
@ -177,6 +181,34 @@ void tst_QtConcurrentFilter::filterThreadPool()
CHECK_FAIL("lambda");
}
void tst_QtConcurrentFilter::filterWithMoveOnlyCallable()
{
const QList<int> intListEven { 2, 4 };
{
QList<int> intList { 1, 2, 3, 4 };
QtConcurrent::filter(intList, KeepEvenIntegersMoveOnly()).waitForFinished();
QCOMPARE(intList, intListEven);
}
{
QList<int> intList { 1, 2, 3, 4 };
QtConcurrent::blockingFilter(intList, KeepEvenIntegersMoveOnly());
QCOMPARE(intList, intListEven);
}
QThreadPool pool;
{
QList<int> intList { 1, 2, 3, 4 };
QtConcurrent::filter(&pool, intList, KeepEvenIntegersMoveOnly()).waitForFinished();
QCOMPARE(intList, intListEven);
}
{
QList<int> intList { 1, 2, 3, 4 };
QtConcurrent::blockingFilter(&pool, intList, KeepEvenIntegersMoveOnly());
QCOMPARE(intList, intListEven);
}
}
template <typename SourceObject,
typename ResultObject,
typename FilterObject>
@ -323,6 +355,52 @@ void tst_QtConcurrentFilter::filteredThreadPool()
}
}
void tst_QtConcurrentFilter::filteredWithMoveOnlyCallable()
{
const QList<int> intList { 1, 2, 3, 4 };
const QList<int> intListEven { 2, 4 };
{
const auto result = QtConcurrent::filtered(intList, KeepEvenIntegersMoveOnly()).results();
QCOMPARE(result, intListEven);
}
{
const auto result = QtConcurrent::filtered(
intList.begin(), intList.end(), KeepEvenIntegersMoveOnly()).results();
QCOMPARE(result, intListEven);
}
{
const auto result = QtConcurrent::blockingFiltered(intList, KeepEvenIntegersMoveOnly());
QCOMPARE(result, intListEven);
}
{
const auto result = QtConcurrent::blockingFiltered<QList<int>>(
intList.begin(), intList.end(), KeepEvenIntegersMoveOnly());
QCOMPARE(result, intListEven);
}
QThreadPool pool;
{
const auto result =
QtConcurrent::filtered(&pool, intList, KeepEvenIntegersMoveOnly()).results();
QCOMPARE(result, intListEven);
}
{
const auto result = QtConcurrent::filtered(&pool, intList.begin(), intList.end(),
KeepEvenIntegersMoveOnly()).results();
QCOMPARE(result, intListEven);
}
{
const auto result =
QtConcurrent::blockingFiltered(&pool, intList, KeepEvenIntegersMoveOnly());
QCOMPARE(result, intListEven);
}
{
const auto result = QtConcurrent::blockingFiltered<QList<int>>(
&pool, intList.begin(), intList.end(), KeepEvenIntegersMoveOnly());
QCOMPARE(result, intListEven);
}
}
template <typename SourceObject,
typename ResultObject,
typename FilterObject,
@ -581,6 +659,61 @@ void tst_QtConcurrentFilter::filteredReducedThreadPool()
}
}
void tst_QtConcurrentFilter::filteredReducedWithMoveOnlyCallables()
{
const QList<int> intList { 1, 2, 3, 4 };
const QList<int> intListEven { 2, 4 };
const auto sum = 6;
{
const auto result =
QtConcurrent::filteredReduced<int>(intList, KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result =
QtConcurrent::filteredReduced<int>(intList.begin(), intList.end(),
KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
QThreadPool pool;
{
const auto result =
QtConcurrent::filteredReduced<int>(&pool, intList, KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::filteredReduced<int>(
&pool, intList.begin(), intList.end(),
KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
&pool, intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
&pool, intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
}
void tst_QtConcurrentFilter::filteredReducedDifferentType()
{
const QList<Number> numberList {1, 2, 3, 4};
@ -911,6 +1044,64 @@ void tst_QtConcurrentFilter::filteredReducedInitialValueThreadPool()
}
}
void tst_QtConcurrentFilter::filteredReducedInitialValueWithMoveOnlyCallables()
{
const QList<int> intList { 1, 2, 3, 4 };
const QList<int> intListEven { 2, 4 };
const auto initial = 10;
const auto sum = 16;
{
const auto result =
QtConcurrent::filteredReduced<int>(intList, KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
const auto result =
QtConcurrent::filteredReduced<int>(intList.begin(), intList.end(),
KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial);
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(),
initial);
QCOMPARE(result, sum);
}
QThreadPool pool;
{
const auto result =
QtConcurrent::filteredReduced<int>(&pool, intList, KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
const auto result =
QtConcurrent::filteredReduced<int>(
&pool, intList.begin(), intList.end(),
KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
&pool, intList, KeepEvenIntegersMoveOnly(), IntSumReduceMoveOnly(), initial);
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingFilteredReduced<int>(
&pool, intList.begin(), intList.end(), KeepEvenIntegersMoveOnly(),
IntSumReduceMoveOnly(), initial);
QCOMPARE(result, sum);
}
}
void tst_QtConcurrentFilter::filteredReducedDifferentTypeInitialValue()
{
const QList<Number> numberList {1, 2, 3, 4};

View File

@ -45,11 +45,14 @@ private slots:
void mapOnRvalue();
void mapped();
void mappedThreadPool();
void mappedWithMoveOnlyCallable();
void mappedReduced();
void mappedReducedThreadPool();
void mappedReducedWithMoveOnlyCallable();
void mappedReducedDifferentType();
void mappedReducedInitialValue();
void mappedReducedInitialValueThreadPool();
void mappedReducedInitialValueWithMoveOnlyCallable();
void mappedReducedDifferentTypeInitialValue();
void assignResult();
void functionOverloads();
@ -98,6 +101,19 @@ public:
}
};
class MultiplyBy2InPlaceMoveOnly
{
public:
MultiplyBy2InPlaceMoveOnly() = default;
MultiplyBy2InPlaceMoveOnly(MultiplyBy2InPlaceMoveOnly &&) = default;
MultiplyBy2InPlaceMoveOnly &operator=(MultiplyBy2InPlaceMoveOnly &&other) = default;
MultiplyBy2InPlaceMoveOnly(const MultiplyBy2InPlaceMoveOnly &) = delete;
MultiplyBy2InPlaceMoveOnly &operator=(const MultiplyBy2InPlaceMoveOnly &) = delete;
void operator()(int &x) { x *= 2; }
};
Q_DECLARE_METATYPE(QList<Number>);
void tst_QtConcurrentMap::map()
@ -138,6 +154,12 @@ void tst_QtConcurrentMap::map()
QCOMPARE(list, QList<int>() << 128 << 256 << 384);
QtConcurrent::map(list.begin(), list.end(), [](int &x){x *= 2;}).waitForFinished();
QCOMPARE(list, QList<int>() << 256 << 512 << 768);
// move-only functor
QtConcurrent::map(list, MultiplyBy2InPlaceMoveOnly()).waitForFinished();
QCOMPARE(list, QList<int>() << 512 << 1024 << 1536);
QtConcurrent::map(list.begin(), list.end(), MultiplyBy2InPlaceMoveOnly()).waitForFinished();
QCOMPARE(list, QList<int>() << 1024 << 2048 << 3072);
}
// functors don't take arguments by reference, making these no-ops
@ -259,6 +281,12 @@ void tst_QtConcurrentMap::blockingMap()
QCOMPARE(list, QList<int>() << 128 << 256 << 384);
QtConcurrent::blockingMap(list.begin(), list.end(), [](int &x) { x *= 2; });
QCOMPARE(list, QList<int>() << 256 << 512 << 768);
// move-only functor
QtConcurrent::blockingMap(list, MultiplyBy2InPlaceMoveOnly());
QCOMPARE(list, QList<int>() << 512 << 1024 << 1536);
QtConcurrent::blockingMap(list.begin(), list.end(), MultiplyBy2InPlaceMoveOnly());
QCOMPARE(list, QList<int>() << 1024 << 2048 << 3072);
}
// functors take arguments by reference, modifying the move-only sequence in place
@ -409,6 +437,23 @@ public:
}
};
class MultiplyBy2MoveOnly
{
public:
MultiplyBy2MoveOnly() = default;
MultiplyBy2MoveOnly(MultiplyBy2MoveOnly &&) = default;
MultiplyBy2MoveOnly &operator=(MultiplyBy2MoveOnly &&other) = default;
MultiplyBy2MoveOnly(const MultiplyBy2MoveOnly &) = delete;
MultiplyBy2MoveOnly &operator=(const MultiplyBy2MoveOnly &) = delete;
int operator()(int x) const
{
int y = x * 2;
return y;
}
};
double intToDouble(int x)
{
return double(x);
@ -642,6 +687,50 @@ void tst_QtConcurrentMap::mappedThreadPool()
}
}
void tst_QtConcurrentMap::mappedWithMoveOnlyCallable()
{
const QList<int> intList { 1, 2, 3 };
const QList<int> intListMultipiedBy2 { 2, 4, 6 };
{
const auto result = QtConcurrent::mapped(intList, MultiplyBy2()).results();
QCOMPARE(result, intListMultipiedBy2);
}
{
const auto result =
QtConcurrent::mapped(intList.begin(), intList.end(), MultiplyBy2()).results();
QCOMPARE(result, intListMultipiedBy2);
}
{
const auto result = QtConcurrent::blockingMapped(intList, MultiplyBy2());
QCOMPARE(result, intListMultipiedBy2);
}
{
const auto result = QtConcurrent::blockingMapped<QList<int>>(intList.begin(), intList.end(),
MultiplyBy2());
QCOMPARE(result, intListMultipiedBy2);
}
QThreadPool pool;
{
const auto result = QtConcurrent::mapped(&pool, intList, MultiplyBy2()).results();
QCOMPARE(result, intListMultipiedBy2);
}
{
const auto result = QtConcurrent::mapped(
&pool, intList.begin(), intList.end(), MultiplyBy2()).results();
QCOMPARE(result, intListMultipiedBy2);
}
{
const auto result = QtConcurrent::blockingMapped(&pool, intList, MultiplyBy2());
QCOMPARE(result, intListMultipiedBy2);
}
{
const auto result = QtConcurrent::blockingMapped<QList<int>>(&pool, intList.begin(),
intList.end(), MultiplyBy2());
QCOMPARE(result, intListMultipiedBy2);
}
}
int intSquare(int x)
{
return x * x;
@ -901,6 +990,56 @@ void tst_QtConcurrentMap::mappedReducedThreadPool()
}
}
void tst_QtConcurrentMap::mappedReducedWithMoveOnlyCallable()
{
const QList<int> intList { 1, 2, 3 };
const auto sum = 12;
{
const auto result = QtConcurrent::mappedReduced<int>(
intList, MultiplyBy2(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result =
QtConcurrent::mappedReduced<int>(intList.begin(), intList.end(),
MultiplyBy2(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(intList, MultiplyBy2(),
IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(
intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
QThreadPool pool;
{
const auto result = QtConcurrent::mappedReduced<int>(&pool, intList, MultiplyBy2(),
IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result =
QtConcurrent::mappedReduced<int>(&pool, intList.begin(), intList.end(),
MultiplyBy2(), IntSumReduceMoveOnly()).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(&pool, intList, MultiplyBy2(),
IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(
&pool, intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly());
QCOMPARE(result, sum);
}
}
void tst_QtConcurrentMap::mappedReducedDifferentType()
{
const QList<int> intList {1, 2, 3};
@ -1196,6 +1335,61 @@ void tst_QtConcurrentMap::mappedReducedInitialValueThreadPool()
}
}
void tst_QtConcurrentMap::mappedReducedInitialValueWithMoveOnlyCallable()
{
const QList<int> intList { 1, 2, 3 };
const auto initialValue = 10;
const auto sum = 22;
{
const auto result =
QtConcurrent::mappedReduced<int>(intList, MultiplyBy2(),
IntSumReduceMoveOnly(), initialValue).result();
QCOMPARE(result, sum);
}
{
const auto result =
QtConcurrent::mappedReduced<int>(intList.begin(), intList.end(), MultiplyBy2(),
IntSumReduceMoveOnly(), initialValue).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(
intList, MultiplyBy2(), IntSumReduceMoveOnly(), initialValue);
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(
intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly(),
initialValue);
QCOMPARE(result, sum);
}
QThreadPool pool;
{
const auto result =
QtConcurrent::mappedReduced<int>(&pool, intList, MultiplyBy2(),
IntSumReduceMoveOnly(), initialValue).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::mappedReduced<int>(&pool, intList.begin(), intList.end(),
MultiplyBy2(), IntSumReduceMoveOnly(),
initialValue).result();
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(
&pool, intList, MultiplyBy2(), IntSumReduceMoveOnly(), initialValue);
QCOMPARE(result, sum);
}
{
const auto result = QtConcurrent::blockingMappedReduced<int>(
&pool, intList.begin(), intList.end(), MultiplyBy2(), IntSumReduceMoveOnly(),
initialValue);
QCOMPARE(result, sum);
}
}
void tst_QtConcurrentMap::mappedReducedDifferentTypeInitialValue()
{
// This is a copy of tst_QtConcurrentMap::mappedReducedDifferentType

View File

@ -44,6 +44,19 @@ public:
}
};
class KeepEvenIntegersMoveOnly
{
public:
KeepEvenIntegersMoveOnly() = default;
KeepEvenIntegersMoveOnly(KeepEvenIntegersMoveOnly &&) = default;
KeepEvenIntegersMoveOnly &operator=(KeepEvenIntegersMoveOnly &&other) = default;
KeepEvenIntegersMoveOnly(const KeepEvenIntegersMoveOnly &) = delete;
KeepEvenIntegersMoveOnly &operator=(const KeepEvenIntegersMoveOnly &) = delete;
bool operator()(int x) { return (x & 1) == 0; }
};
class Number
{
int n;
@ -121,6 +134,19 @@ public:
}
};
class IntSumReduceMoveOnly
{
public:
IntSumReduceMoveOnly() = default;
IntSumReduceMoveOnly(IntSumReduceMoveOnly &&) = default;
IntSumReduceMoveOnly &operator=(IntSumReduceMoveOnly &&other) = default;
IntSumReduceMoveOnly(const IntSumReduceMoveOnly &) = delete;
IntSumReduceMoveOnly &operator=(const IntSumReduceMoveOnly &) = delete;
void operator()(int &sum, int x) { sum += x; }
};
void numberSumReduce(int &sum, const Number &x)
{
sum += x.toInt();