QtConcurrent Namespace

The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives. More...

Header: #include <QtConcurrent>
qmake: QT += concurrent
Since: Qt 4.4

Classes

Types

enum ReduceOption { UnorderedReduce, OrderedReduce, SequentialReduce }
flags ReduceOptions

Functions

void blockingFilter(Sequence &sequence, KeepFunctor keep)
Sequence blockingFiltered(const Sequence &sequence, KeepFunctor keep)
OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)
ResultType blockingFilteredReduced(const Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
ResultType blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
void blockingMap(Sequence &sequence, MapFunctor map)
void blockingMap(Iterator begin, Iterator end, MapFunctor map)
OutputSequence blockingMapped(const InputSequence &sequence, MapFunctor map)
QtPrivate::MapResultType<InputSequence, MapFunctor>::ResultType blockingMapped(const InputSequence &sequence, MapFunctor map)
Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor map)
QtPrivate::MapResultType<Iterator, MapFunctor>::ResultType blockingMapped(Iterator begin, Iterator end, MapFunctor map)
ResultType blockingMappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
ResultType blockingMappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions( QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce ))
QtPrivate::ReduceResultType<ReduceFunctor>::ResultType blockingMappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions( QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce ))
QFuture<void> filter(Sequence &sequence, KeepFunctor keep)
ThreadEngineStarter<void> filterInternal(Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce)
QFuture<Sequence::value_type> filtered(const Sequence &sequence, KeepFunctor keep)
QFuture<qValueType<Iterator>::value_type> filtered(Iterator begin, Iterator end, KeepFunctor keep)
QFuture<ResultType> filteredReduced(const Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
QFuture<ResultType> filteredReduced(Iterator begin, Iterator end, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
QFuture<void> map(Sequence &sequence, MapFunctor map)
QFuture<void> map(Iterator begin, Iterator end, MapFunctor map)
QFuture<QtPrivate::MapResultType<void, MapFunctor>::ResultType> mapped(const Sequence &sequence, MapFunctor map)
QFuture<QtPrivate::MapResultType<void, MapFunctor>::ResultType> mapped(Iterator begin, Iterator end, MapFunctor map)
QFuture<ResultType> mappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
QFuture<QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
QFuture<ResultType> mappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
QFuture<QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> mappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))
QFuture<T> run(Function function, ...)
QFuture<T> run(QThreadPool *pool, Function function, ...)
ThreadEngineStarter<qValueType<Iterator>::value_type> startFiltered(Iterator begin, Iterator end, KeepFunctor functor)
ThreadEngineStarter<Sequence::value_type> startFiltered(const Sequence &sequence, KeepFunctor functor)
ThreadEngineStarter<ResultType> startFilteredReduced(const Sequence &sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
ThreadEngineStarter<ResultType> startFilteredReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
ThreadEngineStarter<void> startMap(Iterator begin, Iterator end, Functor functor)
ThreadEngineStarter<T> startMapped(Iterator begin, Iterator end, Functor functor)
ThreadEngineStarter<T> startMapped(const Sequence &sequence, Functor functor)
ThreadEngineStarter<ResultType> startMappedReduced(const Sequence &sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
ThreadEngineStarter<ResultType> startMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)
ThreadEngineStarter<ThreadEngine::ResultType> startThreadEngine(ThreadEngine *threadEngine)

Detailed Description

The QtConcurrent namespace provides high-level APIs that make it possible to write multi-threaded programs without using low-level threading primitives.

See the Qt Concurrent module documentation for an overview of available functions, or see below for detailed information on each function.

Classes

class IntermediateResults

Type Documentation

enum QtConcurrent::ReduceOption
flags QtConcurrent::ReduceOptions

This enum specifies the order of which results from the map or filter function are passed to the reduce function.

ConstantValueDescription
QtConcurrent::UnorderedReduce0x1Reduction is done in an arbitrary order.
QtConcurrent::OrderedReduce0x2Reduction is done in the order of the original sequence.
QtConcurrent::SequentialReduce0x4Reduction is done sequentially: only one thread will enter the reduce function at a time. (Parallel reduction might be supported in a future version of Qt Concurrent.)

The ReduceOptions type is a typedef for QFlags<ReduceOption>. It stores an OR combination of ReduceOption values.

Function Documentation

void QtConcurrent::blockingFilter(Sequence &sequence, KeepFunctor keep)

Sequence QtConcurrent::blockingFiltered(const Sequence &sequence, KeepFunctor keep)

OutputSequence QtConcurrent::blockingFiltered(Iterator begin, Iterator end, KeepFunctor keep)

ResultType QtConcurrent::blockingFilteredReduced(const Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

void QtConcurrent::blockingMap(Sequence &sequence, MapFunctor map)

void QtConcurrent::blockingMap(Iterator begin, Iterator end, MapFunctor map)

OutputSequence QtConcurrent::blockingMapped(const InputSequence &sequence, MapFunctor map)

QtPrivate::MapResultType<InputSequence, MapFunctor>::ResultType QtConcurrent::blockingMapped(const InputSequence &sequence, MapFunctor map)

Sequence QtConcurrent::blockingMapped(Iterator begin, Iterator end, MapFunctor map)

QtPrivate::MapResultType<Iterator, MapFunctor>::ResultType QtConcurrent::blockingMapped(Iterator begin, Iterator end, MapFunctor map)

ResultType QtConcurrent::blockingMappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

QtPrivate::ReduceResultType<ReduceFunctor>::ResultType QtConcurrent::blockingMappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions( QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce ))

QtPrivate::ReduceResultType<ReduceFunctor>::ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, QtConcurrent::ReduceOptions options = QtConcurrent::ReduceOptions( QtConcurrent::UnorderedReduce | QtConcurrent::SequentialReduce ))

QFuture<void> QtConcurrent::filter(Sequence &sequence, KeepFunctor keep)

ThreadEngineStarter<void> QtConcurrent::filterInternal(Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce)

QFuture<Sequence::value_type> QtConcurrent::filtered(const Sequence &sequence, KeepFunctor keep)

QFuture<qValueType<Iterator>::value_type> QtConcurrent::filtered(Iterator begin, Iterator end, KeepFunctor keep)

QFuture<ResultType> QtConcurrent::filteredReduced(const Sequence &sequence, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

QFuture<ResultType> QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor keep, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

QFuture<void> QtConcurrent::map(Sequence &sequence, MapFunctor map)

QFuture<void> QtConcurrent::map(Iterator begin, Iterator end, MapFunctor map)

QFuture<QtPrivate::MapResultType<void, MapFunctor>::ResultType> QtConcurrent::mapped(const Sequence &sequence, MapFunctor map)

QFuture<QtPrivate::MapResultType<void, MapFunctor>::ResultType> QtConcurrent::mapped(Iterator begin, Iterator end, MapFunctor map)

QFuture<ResultType> QtConcurrent::mappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

QFuture<QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> QtConcurrent::mappedReduced(const Sequence &sequence, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

QFuture<ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

QFuture<QtPrivate::ReduceResultType<ReduceFunctor>::ResultType> QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor map, ReduceFunctor reduce, ReduceOptions options = ReduceOptions( UnorderedReduce | SequentialReduce ))

QFuture<T> QtConcurrent::run(Function function, ...)

Equivalent to

 QtConcurrent::run(QThreadPool::globalInstance(), function, ...);

Runs function in a separate thread. The thread is taken from the global QThreadPool. Note that function may not run immediately; function will only be run once a thread becomes available.

T is the same type as the return value of function. Non-void return values can be accessed via the QFuture::result() function.

Note: The QFuture returned can only be used to query for the running/finished status and the return value of the function. In particular, canceling or pausing can be issued only if the computations behind the future has not been started.

See also Concurrent Run and QThreadPool::start().

QFuture<T> QtConcurrent::run(QThreadPool *pool, Function function, ...)

Schedules function on pool. Note that function may not run immediately; function will only be run once a thread becomes available.

T is the same type as the return value of function. Non-void return values can be accessed via the QFuture::result() function.

Note: The QFuture returned can only be used to query for the running/finished status and the return value of the function. In particular, canceling or pausing can be issued only if the computations behind the future has not been started.

This function was introduced in Qt 5.4.

See also Concurrent Run and QThreadPool::start().

ThreadEngineStarter<qValueType<Iterator>::value_type> QtConcurrent::startFiltered(Iterator begin, Iterator end, KeepFunctor functor)

ThreadEngineStarter<Sequence::value_type> QtConcurrent::startFiltered(const Sequence &sequence, KeepFunctor functor)

ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(const Sequence &sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)

ThreadEngineStarter<ResultType> QtConcurrent::startFilteredReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)

ThreadEngineStarter<void> QtConcurrent::startMap(Iterator begin, Iterator end, Functor functor)

ThreadEngineStarter<T> QtConcurrent::startMapped(Iterator begin, Iterator end, Functor functor)

ThreadEngineStarter<T> QtConcurrent::startMapped(const Sequence &sequence, Functor functor)

ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(const Sequence &sequence, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)

ThreadEngineStarter<ResultType> QtConcurrent::startMappedReduced(Iterator begin, Iterator end, MapFunctor mapFunctor, ReduceFunctor reduceFunctor, ReduceOptions options)

ThreadEngineStarter<ThreadEngine::ResultType> QtConcurrent::startThreadEngine(ThreadEngine *threadEngine)