QtConcurrent Namespace

您所在的位置:网站首页 蚂蚁集团员工期权拆分 QtConcurrent Namespace

QtConcurrent Namespace

2024-04-06 02:24| 来源: 网络整理| 查看: 265

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 CMake: find_package(Qt6 REQUIRED COMPONENTS Concurrent) target_link_libraries(mytarget PRIVATE Qt6::Concurrent) qmake: QT += concurrent QtConcurrent is part of Threading Classes. Classes (since 6.0) class QTaskBuilder Types enum class FutureResult { Ignore } InvokeResultType enum ReduceOption { UnorderedReduce, OrderedReduce, SequentialReduce } flags ReduceOptions Functions void blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction) void blockingFilter(Sequence &sequence, KeepFunctor &&filterFunction) std::decay_t blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction) std::decay_t blockingFiltered(Sequence &&sequence, KeepFunctor &&filterFunction) OutputSequence blockingFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction) OutputSequence blockingFiltered(Iterator begin, Iterator end, KeepFunctor &&filterFunction) ResultType blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingFilteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingFilteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) void blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor function) void blockingMap(Sequence &&sequence, MapFunctor &&function) void blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function) void blockingMap(Iterator begin, Iterator end, MapFunctor &&function) OutputSequence blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&function) OutputSequence blockingMapped(InputSequence &&sequence, MapFunctor &&function) Sequence blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function) Sequence blockingMapped(Iterator begin, Iterator end, MapFunctor &&function) ResultType blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) ResultType blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction) QFuture filter(Sequence &sequence, KeepFunctor &&filterFunction) QFuture filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction) QFuture filtered(Sequence &&sequence, KeepFunctor &&filterFunction) QFuture filtered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction) QFuture filtered(Iterator begin, Iterator end, KeepFunctor &&filterFunction) QFuture filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture filteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture map(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function) QFuture map(Sequence &&sequence, MapFunctor &&function) QFuture map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function) QFuture map(Iterator begin, Iterator end, MapFunctor &&function) QFuture mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function) QFuture mapped(Sequence &&sequence, MapFunctor &&function) QFuture mapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function) QFuture mapped(Iterator begin, Iterator end, MapFunctor &&function) QFuture mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce)) QFuture run(Function function, ...) QFuture run(QThreadPool *pool, Function function, ...) (since 6.0) QtConcurrent::QTaskBuilder task(Task &&task) Detailed Description

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

Classes class QTaskBuilder

The QTaskBuilder class is used for adjusting task parameters. More...

Type Documentation enum class QtConcurrent::FutureResult

This enum type is used to invoke a special overload of QtConcurrent::QTaskBuilder::spawn(QtConcurrent::FutureResult) that doesn't return a future object.

ConstantValueDescription QtConcurrent::FutureResult::Ignore0An auxiliary tag which introduced to improve code readability. [alias] InvokeResultType

The simplified definition of this type looks like this:

template using InvokeResultType = std::invoke_result_t;

The real implementation also contains a compile-time check for whether the task can be invoked with the specified arguments or not.

enum QtConcurrent::ReduceOptionflags 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. It stores an OR combination of ReduceOption values.

Function Documentation template void QtConcurrent::blockingFilter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true, the item is kept in sequence; otherwise, the item is removed from sequence.

Note that this method doesn't have an overload working with iterators, because it invalidates the iterators of the sequence it operates on.

Note: This function will block until all items in the sequence have been processed.

See also Concurrent Filter and Filter-Reduce.

template void QtConcurrent::blockingFilter(Sequence &sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence. If filterFunction returns true, the item is kept in sequence; otherwise, the item is removed from sequence.

Note that this method doesn't have an overload working with iterators, because it invalidates the iterators of the sequence it operates on.

Note: This function will block until all items in the sequence have been processed.

See also Concurrent Filter and Filter-Reduce.

template std::decay_t QtConcurrent::blockingFiltered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence and returns a new Sequence of kept items. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

Note: This function will block until all items in the sequence have been processed.

See also filtered() and Concurrent Filter and Filter-Reduce.

template std::decay_t QtConcurrent::blockingFiltered(Sequence &&sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

Note: This function will block until all items in the sequence have been processed.

See also filtered() and Concurrent Filter and Filter-Reduce.

template OutputSequence QtConcurrent::blockingFiltered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction)

Calls filterFunction once for each item from begin to end and returns a new Sequence of kept items. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filtered() and Concurrent Filter and Filter-Reduce.

template OutputSequence QtConcurrent::blockingFiltered(Iterator begin, Iterator end, KeepFunctor &&filterFunction)

Calls filterFunction once for each item from begin to end and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filtered() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

Note: This function will block until all items in the sequence have been processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

Note: This function will block until all items in the sequence have been processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

Note: This function will block until all items in the sequence have been processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

Note: This function will block until all items in the sequence have been processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template ResultType QtConcurrent::blockingFilteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also filteredReduced() and Concurrent Filter and Filter-Reduce.

template void QtConcurrent::blockingMap(QThreadPool *pool, Sequence &&sequence, MapFunctor function)

Calls function once for each item in sequence. All calls to function are invoked from the threads taken from the QThreadPool pool. The function takes a reference to the item, so that any modifications done to the item will appear in sequence.

Note: This function will block until all items in the sequence have been processed.

See also map() and Concurrent Map and Map-Reduce.

template void QtConcurrent::blockingMap(Sequence &&sequence, MapFunctor &&function)

Calls function once for each item in sequence. The function takes a reference to the item, so that any modifications done to the item will appear in sequence.

Note: This function will block until all items in the sequence have been processed.

See also map() and Concurrent Map and Map-Reduce.

template void QtConcurrent::blockingMap(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end. All calls to function are invoked from the threads taken from the QThreadPool pool. The function takes a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also map() and Concurrent Map and Map-Reduce.

template void QtConcurrent::blockingMap(Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end. The function takes a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also map() and Concurrent Map and Map-Reduce.

template OutputSequence QtConcurrent::blockingMapped(QThreadPool *pool, InputSequence &&sequence, MapFunctor &&function)

Calls function once for each item in sequence and returns an OutputSequence containing the results. All calls to function are invoked from the threads taken from the QThreadPool pool. The type of the results will match the type returned by the MapFunctor.

Note: This function will block until all items in the sequence have been processed.

See also mapped() and Concurrent Map and Map-Reduce.

template OutputSequence QtConcurrent::blockingMapped(InputSequence &&sequence, MapFunctor &&function)

Calls function once for each item in sequence and returns an OutputSequence containing the results. The type of the results will match the type returned by the MapFunctor.

Note: This function will block until all items in the sequence have been processed.

See also mapped() and Concurrent Map and Map-Reduce.

template Sequence QtConcurrent::blockingMapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end and returns a container with the results. All calls to function are invoked from the threads taken from the QThreadPool pool. You can specify the type of container as the a template argument, like this:

QList ints = QtConcurrent::blockingMapped(beginIterator, endIterator, fn);

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also mapped() and Concurrent Map and Map-Reduce.

template Sequence QtConcurrent::blockingMapped(Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end and returns a container with the results. You can specify the type of container as the a template argument, like this:

QList ints = QtConcurrent::blockingMapped(beginIterator, endIterator, fn);

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also mapped() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

Note: This function will block until all items in the sequence have been processed.

See also mapped() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

Note: This function will block until all items in the sequence have been processed.

See also mapped() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

Note: This function will block until all items in the sequence have been processed.

See also mapped() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

Note: This function will block until all items in the sequence have been processed.

See also mapped() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also blockingMappedReduced() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also blockingMappedReduced() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also blockingMappedReduced() and Concurrent Map and Map-Reduce.

template ResultType QtConcurrent::blockingMappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined.

Note: This function will block until the iterator reaches the end of the sequence being processed.

See also blockingMappedReduced() and Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::filter(QThreadPool *pool, Sequence &sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true, the item is kept in sequence; otherwise, the item is removed from sequence.

Note that this method doesn't have an overload working with iterators, because it invalidates the iterators of the sequence it operates on.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filter(Sequence &sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence. If filterFunction returns true, the item is kept in sequence; otherwise, the item is removed from sequence.

Note that this method doesn't have an overload working with iterators, because it invalidates the iterators of the sequence it operates on.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filtered(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence and returns a new Sequence of kept items. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filtered(Sequence &&sequence, KeepFunctor &&filterFunction)

Calls filterFunction once for each item in sequence and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filtered(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction)

Calls filterFunction once for each item from begin to end and returns a new Sequence of kept items. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filtered(Iterator begin, Iterator end, KeepFunctor &&filterFunction)

Calls filterFunction once for each item from begin to end and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(QThreadPool *pool, Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(Sequence &&sequence, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(QThreadPool *pool, Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. All calls to filterFunction are invoked from the threads taken from the QThreadPool pool. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::filteredReduced(Iterator begin, Iterator end, KeepFunctor &&filterFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls filterFunction once for each item from begin to end. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, the reduceFunction is called in the order of the original sequence.

See also Concurrent Filter and Filter-Reduce.

template QFuture QtConcurrent::map(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function)

Calls function once for each item in sequence. All calls to function are invoked from the threads taken from the QThreadPool pool. The function takes a reference to the item, so that any modifications done to the item will appear in sequence.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::map(Sequence &&sequence, MapFunctor &&function)

Calls function once for each item in sequence. The function takes a reference to the item, so that any modifications done to the item will appear in sequence.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::map(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end. All calls to function are invoked from the threads taken from the QThreadPool pool. The function takes a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::map(Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end. The function takes a reference to the item, so that any modifications done to the item will appear in the sequence which the iterators belong to.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mapped(QThreadPool *pool, Sequence &&sequence, MapFunctor &&function)

Calls function once for each item in sequence and returns a future with each mapped item as a result. All calls to function are invoked from the threads taken from the QThreadPool pool. You can use QFuture::const_iterator or QFutureIterator to iterate through the results.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mapped(Sequence &&sequence, MapFunctor &&function)

Calls function once for each item in sequence and returns a future with each mapped item as a result. You can use QFuture::const_iterator or QFutureIterator to iterate through the results.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mapped(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end and returns a future with each mapped item as a result. All calls to function are invoked from the threads taken from the QThreadPool pool. You can use QFuture::const_iterator or QFutureIterator to iterate through the results.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mapped(Iterator begin, Iterator end, MapFunctor &&function)

Calls function once for each item from begin to end and returns a future with each mapped item as a result. You can use QFuture::const_iterator or QFutureIterator to iterate through the results.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(QThreadPool *pool, Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(Sequence &&sequence, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. By default, the order in which reduceFunction is called is undefined.

Note: QtConcurrent::OrderedReduce results in the ordered reduction.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. The return value of each mapFunction is passed to reduceFunction.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. By default, the order in which reduceFunction is called is undefined.

Note: QtConcurrent::OrderedReduce results in the ordered reduction.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(QThreadPool *pool, Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. All calls to mapFunction are invoked from the threads taken from the QThreadPool pool. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. By default, the order in which reduceFunction is called is undefined.

Note: QtConcurrent::OrderedReduce results in the ordered reduction.

See also Concurrent Map and Map-Reduce.

template QFuture QtConcurrent::mappedReduced(Iterator begin, Iterator end, MapFunctor &&mapFunction, ReduceFunctor &&reduceFunction, InitialValueType &&initialValue, QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))

Calls mapFunction once for each item from begin to end. The return value of each mapFunction is passed to reduceFunction. The result value is initialized to initialValue when the function is called, and the first call to reduceFunction will operate on this value.

Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. By default, the order in which reduceFunction is called is undefined.

Note: QtConcurrent::OrderedReduce results in the ordered reduction.

See also Concurrent Map and Map-Reduce.

template QFuture 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.

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

In basic mode 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.

In run with promise mode, the function is expected to return void and must take an additional argument of QPromise & type, placed as a first argument in function's argument list. T is the result type and it is the same for the returned QFuture.

In run with promise mode, similar to basic mode, the QFuture returned can be used to query for the running/finished status and the value reported by the function. In addition, it may be used for suspending or canceling the running task, fetching multiple results from the called function or monitoring progress reported by the function.

See also Concurrent Run (basic mode), Concurrent Run With Promise, and QThreadPool::start().

template QFuture 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.

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

In basic mode 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.

In run with promise mode, the function is expected to return void and must take an additional argument of QPromise & type, placed as a first argument in function's argument list. T is the result type and it is the same for the returned QFuture.

In run with promise mode, similar to basic mode, the QFuture returned can be used to query for the running/finished status and the value reported by the function. In addition, it may be used for suspending or canceling the running task, fetching multiple results from the called function or monitoring progress reported by the function.

See also Concurrent Run (basic mode), Concurrent Run With Promise, and QThreadPool::start().

[since 6.0] template QtConcurrent::QTaskBuilder QtConcurrent::task(Task &&task)

Creates an instance of QtConcurrent::QTaskBuilder. This object can be used to adjust some parameters and run task in a separate thread.

This function was introduced in Qt 6.0.

See also Concurrent Task and QtConcurrent::QTaskBuilder.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3