summaryrefslogtreecommitdiffstats
path: root/src/concurrent/qtconcurrentreducekernel.h
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/qtconcurrentreducekernel.h
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/qtconcurrentreducekernel.h')
-rw-r--r--src/concurrent/qtconcurrentreducekernel.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/concurrent/qtconcurrentreducekernel.h b/src/concurrent/qtconcurrentreducekernel.h
index 333d358f18..cdddfdde0d 100644
--- a/src/concurrent/qtconcurrentreducekernel.h
+++ b/src/concurrent/qtconcurrentreducekernel.h
@@ -232,6 +232,13 @@ struct SequenceHolder2 : private QtPrivate::SequenceHolder<Sequence>, public Bas
reduceOptions)
{ }
+ SequenceHolder2(QThreadPool *pool, Sequence &&_sequence, Functor1 functor1, Functor2 functor2,
+ ReduceOptions reduceOptions)
+ : QtPrivate::SequenceHolder<Sequence>(std::move(_sequence)),
+ Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor1, functor2,
+ reduceOptions)
+ { }
+
template<typename InitialValueType>
SequenceHolder2(QThreadPool *pool, const Sequence &_sequence, Functor1 functor1,
Functor2 functor2, InitialValueType &&initialValue, ReduceOptions reduceOptions)
@@ -240,6 +247,14 @@ struct SequenceHolder2 : private QtPrivate::SequenceHolder<Sequence>, public Bas
std::forward<InitialValueType>(initialValue), reduceOptions)
{ }
+ template<typename InitialValueType>
+ SequenceHolder2(QThreadPool *pool, Sequence &&_sequence, Functor1 functor1, Functor2 functor2,
+ InitialValueType &&initialValue, ReduceOptions reduceOptions)
+ : QtPrivate::SequenceHolder<Sequence>(std::move(_sequence)),
+ Base(pool, this->sequence.cbegin(), this->sequence.cend(), functor1, functor2,
+ std::forward<InitialValueType>(initialValue), reduceOptions)
+ { }
+
void finish() override
{
Base::finish();