summaryrefslogtreecommitdiffstats
path: root/src/concurrent/qtconcurrentmap.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/qtconcurrentmap.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/qtconcurrentmap.cpp')
-rw-r--r--src/concurrent/qtconcurrentmap.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/src/concurrent/qtconcurrentmap.cpp b/src/concurrent/qtconcurrentmap.cpp
index 43763a441f..43313feeef 100644
--- a/src/concurrent/qtconcurrentmap.cpp
+++ b/src/concurrent/qtconcurrentmap.cpp
@@ -104,12 +104,12 @@
*/
/*!
- \fn [qtconcurrentmapkernel-3] ThreadEngineStarter<T> QtConcurrent::startMapped(const Sequence &sequence, Functor functor)
+ \fn [qtconcurrentmapkernel-3] ThreadEngineStarter<T> QtConcurrent::startMapped(Sequence &&sequence, Functor functor)
\internal
*/
/*!
- \fn [qtconcurrentmapkernel-4] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(const Sequence & sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
+ \fn [qtconcurrentmapkernel-4] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Sequence && sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
\internal
*/
@@ -119,7 +119,7 @@
*/
/*!
- \fn [qtconcurrentmapkernel-6] ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(const 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
*/
@@ -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
@@ -362,7 +362,7 @@
*/
/*!
- \fn template <typename Sequence, typename MapFunctor> QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> QtConcurrent::mapped(QThreadPool *pool, const 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(const 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
@@ -404,7 +404,7 @@
*/
/*!
- \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> QFuture<ResultType> QtConcurrent::mappedReduced(QThreadPool *pool, const 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(const 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, const 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(const 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.
@@ -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
@@ -584,7 +584,7 @@
*/
/*!
- \fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(QThreadPool *pool, const 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(const InputSequence &sequence, MapFunctor function)
+ \fn template <typename OutputSequence, typename InputSequence, typename MapFunctor> OutputSequence QtConcurrent::blockingMapped(const 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 my the MapFunctor.
@@ -642,7 +642,7 @@
*/
/*!
- \fn template <typename ResultType, typename Sequence, typename MapFunctor, typename ReduceFunctor> ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, const 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(const 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, const 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(const 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.