summaryrefslogtreecommitdiffstats
path: root/src/concurrent/qtconcurrentfilter.cpp
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2020-09-24 11:07:32 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2020-09-30 15:28:01 +0200
commit2e27b98cffcd96d4e1d8a0b5836a36dc9929f676 (patch)
tree5276d28f7a834fa59e653a9cb887f55b72891fe3 /src/concurrent/qtconcurrentfilter.cpp
parent5c7307775d32ae0a54acad8ae7a1c9d3cff7d45e (diff)
Use universal references in QtConcurrent
Changed QtConcurrent algorithms to take the passed sequences as universal references, where it makes sense. In addition to avoiding to create extra copies when passing rvalues, this change allows passing temporary container adaptors to QtConcurrent::map (e.g. see the example in the ticket and the new test-cases). Task-number: QTBUG-83170 Change-Id: Ia7c0833f4ec1d860294fa5214cd53934b65ff084 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/concurrent/qtconcurrentfilter.cpp')
-rw-r--r--src/concurrent/qtconcurrentfilter.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/concurrent/qtconcurrentfilter.cpp b/src/concurrent/qtconcurrentfilter.cpp
index ce484dcef9..298e1684fc 100644
--- a/src/concurrent/qtconcurrentfilter.cpp
+++ b/src/concurrent/qtconcurrentfilter.cpp
@@ -263,7 +263,7 @@
*/
/*!
- \fn template <typename Sequence, typename KeepFunctor> QFuture<Sequence::value_type> QtConcurrent::filtered(QThreadPool *pool, const 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(const 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
@@ -309,7 +309,7 @@
*/
/*!
- \fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::filteredReduced(QThreadPool *pool, const 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(const 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, const 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(const 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
@@ -500,7 +500,7 @@
*/
/*!
- \fn template <typename Sequence, typename KeepFunctor> Sequence QtConcurrent::blockingFiltered(QThreadPool *pool, const 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(const 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
@@ -556,7 +556,7 @@
*/
/*!
- \fn template <typename ResultType, typename Sequence, typename KeepFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, const 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(const 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, const 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(const 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
@@ -741,12 +741,12 @@
*/
/*!
- \fn [QtConcurrent-3] ThreadEngineStarter<typename Sequence::value_type> QtConcurrent::startFiltered(QThreadPool *pool, const 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, const 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
*/
@@ -756,7 +756,7 @@
*/
/*!
- \fn [QtConcurrent-6] ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(QThreadPool *pool, const 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
*/