From 2e27b98cffcd96d4e1d8a0b5836a36dc9929f676 Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Thu, 24 Sep 2020 11:07:32 +0200 Subject: Use universal references in QtConcurrent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jarek Kobus Reviewed-by: MÃ¥rten Nordheim --- src/concurrent/qtconcurrentmap.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/concurrent/qtconcurrentmap.cpp') diff --git a/src/concurrent/qtconcurrentmap.cpp b/src/concurrent/qtconcurrentmap.cpp index 43763a441fd..43313feeef3 100644 --- a/src/concurrent/qtconcurrentmap.cpp +++ b/src/concurrent/qtconcurrentmap.cpp @@ -104,12 +104,12 @@ */ /*! - \fn [qtconcurrentmapkernel-3] ThreadEngineStarter QtConcurrent::startMapped(const Sequence &sequence, Functor functor) + \fn [qtconcurrentmapkernel-3] ThreadEngineStarter QtConcurrent::startMapped(Sequence &&sequence, Functor functor) \internal */ /*! - \fn [qtconcurrentmapkernel-4] ThreadEngineStarter QtConcurrent::startMappedReduced(const Sequence & sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options) + \fn [qtconcurrentmapkernel-4] ThreadEngineStarter QtConcurrent::startMappedReduced(Sequence && sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options) \internal */ @@ -119,7 +119,7 @@ */ /*! - \fn [qtconcurrentmapkernel-6] ThreadEngineStarter QtConcurrent::startMappedReduced(const Sequence & sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ResultType &&initialValue, ReduceOptions options) + \fn [qtconcurrentmapkernel-6] ThreadEngineStarter QtConcurrent::startMappedReduced(Sequence && sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ResultType &&initialValue, ReduceOptions options) \internal */ @@ -320,7 +320,7 @@ */ /*! - \fn template QFuture QtConcurrent::map(QThreadPool *pool, Sequence &sequence, MapFunctor function) + \fn template QFuture 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 QFuture QtConcurrent::map(Sequence &sequence, MapFunctor function) + \fn template QFuture 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 QFuture> QtConcurrent::mapped(QThreadPool *pool, const Sequence &sequence, MapFunctor function) + \fn template QFuture> 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 QFuture> QtConcurrent::mapped(const Sequence &sequence, MapFunctor function) + \fn template QFuture> 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 QFuture QtConcurrent::mappedReduced(QThreadPool *pool, const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template QFuture 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 QFuture QtConcurrent::mappedReduced(const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template QFuture 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 QFuture QtConcurrent::mappedReduced(QThreadPool *pool, const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions) + \fn template QFuture 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 QFuture QtConcurrent::mappedReduced(const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions) + \fn template QFuture 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 void QtConcurrent::blockingMap(QThreadPool *pool, Sequence &sequence, MapFunctor function) + \fn template 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 void QtConcurrent::blockingMap(Sequence &sequence, MapFunctor function) + \fn template 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 OutputSequence QtConcurrent::blockingMapped(QThreadPool *pool, const InputSequence &sequence, MapFunctor function) + \fn template 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 OutputSequence QtConcurrent::blockingMapped(const InputSequence &sequence, MapFunctor function) + \fn template 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 ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template 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 ResultType QtConcurrent::blockingMappedReduced(const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, QtConcurrent::ReduceOptions reduceOptions) + \fn template 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 ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions) + \fn template 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 ResultType QtConcurrent::blockingMappedReduced(const Sequence &sequence, MapFunctor mapFunction, ReduceFunctor reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions) + \fn template 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. -- cgit v1.2.3