QtConcurrent 名稱空間

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

頭: #include <QtConcurrent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Concurrent)
target_link_libraries(mytarget PRIVATE Qt6::Concurrent)
qmake: QT += concurrent

(從 6.0 起) class QTaskBuilder

類型

枚舉類 FutureResult { Ignore }
InvokeResultType
enum ReduceOption { UnorderedReduce, OrderedReduce, SequentialReduce }
flags ReduceOptions

函數

void blockingFilter (Sequence & sequence , KeepFunctor && filterFunction )
void blockingFilter (QThreadPool * pool , Sequence & sequence , KeepFunctor && filterFunction )
std::decay_t<Sequence> blockingFiltered (Sequence && sequence , KeepFunctor && filterFunction )
OutputSequence blockingFiltered (Iterator begin , Iterator end , KeepFunctor && filterFunction )
std::decay_t<Sequence> blockingFiltered (QThreadPool * pool , Sequence && sequence , KeepFunctor && filterFunction )
OutputSequence blockingFiltered (QThreadPool * pool , Iterator begin , Iterator end , KeepFunctor && filterFunction )
ResultType blockingFilteredReduced (Sequence && sequence , 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 , Sequence && sequence , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
ResultType blockingFilteredReduced (Sequence && sequence , 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))
ResultType blockingFilteredReduced (QThreadPool * pool , Iterator begin , Iterator end , 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 (QThreadPool * pool , Iterator begin , Iterator end , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
void blockingMap (Sequence && sequence , MapFunctor && function )
void blockingMap (Iterator begin , Iterator end , MapFunctor && function )
void blockingMap (QThreadPool * pool , Sequence && sequence , MapFunctor function )
void blockingMap (QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && function )
OutputSequence blockingMapped (InputSequence && sequence , MapFunctor && function )
Sequence blockingMapped (Iterator begin , Iterator end , MapFunctor && function )
OutputSequence blockingMapped (QThreadPool * pool , InputSequence && sequence , MapFunctor && function )
Sequence blockingMapped (QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && function )
ResultType blockingMappedReduced (Sequence && sequence , 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 , Sequence && sequence , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
ResultType blockingMappedReduced (Sequence && sequence , 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))
ResultType blockingMappedReduced (QThreadPool * pool , Iterator begin , Iterator end , 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 (QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<void> filter (Sequence & sequence , KeepFunctor && filterFunction )
QFuture<void> filter (QThreadPool * pool , Sequence & sequence , KeepFunctor && filterFunction )
QFuture<typename std::decay_t<Sequence>::value_type> filtered (Sequence && sequence , KeepFunctor && filterFunction )
QFuture<typename qValueType<Iterator>::value_type> filtered (Iterator begin , Iterator end , KeepFunctor && filterFunction )
QFuture<typename std::decay_t<Sequence>::value_type> filtered (QThreadPool * pool , Sequence && sequence , KeepFunctor && filterFunction )
QFuture<typename qValueType<Iterator>::value_type> filtered (QThreadPool * pool , Iterator begin , Iterator end , KeepFunctor && filterFunction )
QFuture<ResultType> filteredReduced (Sequence && sequence , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> filteredReduced (Iterator begin , Iterator end , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> filteredReduced (QThreadPool * pool , Sequence && sequence , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> filteredReduced (Sequence && sequence , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> filteredReduced (Iterator begin , Iterator end , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> filteredReduced (QThreadPool * pool , Iterator begin , Iterator end , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> filteredReduced (QThreadPool * pool , Sequence && sequence , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> filteredReduced (QThreadPool * pool , Iterator begin , Iterator end , KeepFunctor && filterFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<void> map (Sequence && sequence , MapFunctor && function )
QFuture<void> map (Iterator begin , Iterator end , MapFunctor && function )
QFuture<void> map (QThreadPool * pool , Sequence && sequence , MapFunctor && function )
QFuture<void> map (QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && function )
QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> mapped (Sequence && sequence , MapFunctor && function )
QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> mapped (Iterator begin , Iterator end , MapFunctor && function )
QFuture<QtPrivate::MapResultType<Sequence, MapFunctor>> mapped (QThreadPool * pool , Sequence && sequence , MapFunctor && function )
QFuture<QtPrivate::MapResultType<Iterator, MapFunctor>> mapped (QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && function )
QFuture<ResultType> mappedReduced (Sequence && sequence , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> mappedReduced (Iterator begin , Iterator end , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> mappedReduced (QThreadPool * pool , Sequence && sequence , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> mappedReduced (Sequence && sequence , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> mappedReduced (Iterator begin , Iterator end , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> mappedReduced (QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> mappedReduced (QThreadPool * pool , Sequence && sequence , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<ResultType> mappedReduced (QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && mapFunction , ReduceFunctor && reduceFunction , InitialValueType && initialValue , QtConcurrent::ReduceOptions reduceOptions = ReduceOptions(UnorderedReduce | SequentialReduce))
QFuture<T> run (Function function , ...)
QFuture<T> run (QThreadPool * pool , Function function , ...)
(從 6.0 起) QtConcurrent::QTaskBuilder<Task> task (Task && task )

詳細描述

Qt Concurrent 模塊文檔編製瞭解可用函數的概述,或見下文瞭解每個函數的詳細信息。

優化包括

If you include the <QtConcurrent> header, the entire Qt Concurrent module with the entire Qt Core module will be included, which may increase compilation times and binary sizes. To use individual functions from the QtConcurrent namespace, you can include more specific headers.

The table below lists the functions in the QtConcurrent namespace and their corresponding headers:

函數
QtConcurrent::run () <QtConcurrentRun>
QtConcurrent::task () <QtConcurrentTask>
QtConcurrent::filter (), QtConcurrent::filtered (), QtConcurrent::filteredReduced () <QtConcurrentFilter>
QtConcurrent::map (), QtConcurrent::mapped (), QtConcurrent::mappedReduced () <QtConcurrentMap>

class QTaskBuilder

QTaskBuilder 類用於調節任務參數。 更多...

類型文檔編製

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.

常量 描述
QtConcurrent::FutureResult::Ignore 0 An auxiliary tag which introduced to improve code readability.

[alias] InvokeResultType

The simplified definition of this type looks like this:

template <class Task, class ...Args>
using InvokeResultType = std::invoke_result_t<std::decay_t<Task>, std::decay_t<Args>...>;
					

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

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.

常量 描述
QtConcurrent::UnorderedReduce 0x1 按任意次序履行縮減。
QtConcurrent::OrderedReduce 0x2 Reduction is done in the order of the original sequence.
QtConcurrent::SequentialReduce 0x4 Reduction 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.

函數文檔編製

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

調用 filterFunction once for each item in sequence 。若 filterFunction 返迴 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.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 並發過濾和過濾縮減 .

template <typename Sequence, typename KeepFunctor> void QtConcurrent:: blockingFilter ( QThreadPool * pool , Sequence & sequence , KeepFunctor && filterFunction )

調用 filterFunction once for each item in sequence . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 並發過濾和過濾縮減 .

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

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

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 filtered () 和 並發過濾和過濾縮減 .

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

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

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 filtered () 和 並發過濾和過濾縮減 .

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

調用 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 。若 filterFunction 返迴 true , a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 filtered () 和 並發過濾和過濾縮減 .

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

調用 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 。若 filterFunction 返迴 true , a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 filtered () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 filteredReduced () 和 並發過濾和過濾縮減 .

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

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

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 map () 和 並發映射和映射縮減 .

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

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

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 map () 和 並發映射和映射縮減 .

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

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

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 map () 和 並發映射和映射縮減 .

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

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

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 map () 和 並發映射和映射縮減 .

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

調用 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.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 mapped () 和 並發映射和映射縮減 .

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

調用 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<int> ints = QtConcurrent::blockingMapped<QList<int> >(beginIterator, endIterator, fn);
					

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 mapped () 和 並發映射和映射縮減 .

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

調用 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.

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 mapped () 和 並發映射和映射縮減 .

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

調用 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<int> ints = QtConcurrent::blockingMapped<QList<int> >(beginIterator, endIterator, fn);
					

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 mapped () 和 並發映射和映射縮減 .

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

調用 mapFunction once for each item in sequence . The return value of each mapFunction 被傳遞給 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 .

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 mapped () 和 並發映射和映射縮減 .

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

調用 mapFunction once for each item from begin to end . The return value of each mapFunction 被傳遞給 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.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 blockingMappedReduced () 和 並發映射和映射縮減 .

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

調用 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 被傳遞給 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 .

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 mapped () 和 並發映射和映射縮減 .

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 = ReduceOptions(UnorderedReduce | SequentialReduce))

調用 mapFunction once for each item in sequence . The return value of each mapFunction 被傳遞給 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 .

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 mapped () 和 並發映射和映射縮減 .

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

調用 mapFunction once for each item from begin to end . The return value of each mapFunction 被傳遞給 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.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 blockingMappedReduced () 和 並發映射和映射縮減 .

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

調用 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 被傳遞給 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.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 blockingMappedReduced () 和 並發映射和映射縮減 .

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 = ReduceOptions(UnorderedReduce | SequentialReduce))

調用 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 被傳遞給 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 .

注意: 此函數將阻塞,直到已處理所有序列項。

另請參閱 mapped () 和 並發映射和映射縮減 .

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

調用 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 被傳遞給 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.

注意: 此函數將阻塞,直到迭代器到達正處理序列的末尾。

另請參閱 blockingMappedReduced () 和 並發映射和映射縮減 .

template <typename Sequence, typename KeepFunctor> QFuture < void > QtConcurrent:: filter ( Sequence & sequence , KeepFunctor && filterFunction )

調用 filterFunction once for each item in sequence 。若 filterFunction 返迴 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.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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.

另請參閱 並發過濾和過濾縮減 .

template <typename Sequence, typename KeepFunctor> QFuture < typename std::decay_t < Sequence > ::value_type > QtConcurrent:: filtered ( Sequence && sequence , KeepFunctor && filterFunction )

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

另請參閱 並發過濾和過濾縮減 .

template <typename Iterator, typename KeepFunctor> QFuture < typename qValueType < Iterator > ::value_type > QtConcurrent:: filtered ( Iterator begin , Iterator end , KeepFunctor && filterFunction )

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

另請參閱 並發過濾和過濾縮減 .

template <typename Sequence, typename KeepFunctor> QFuture < typename std::decay_t < Sequence > ::value_type > QtConcurrent:: filtered ( QThreadPool * pool , Sequence && sequence , KeepFunctor && filterFunction )

調用 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 。若 filterFunction 返迴 true , a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

另請參閱 並發過濾和過濾縮減 .

template <typename Iterator, typename KeepFunctor> QFuture < typename qValueType < Iterator > ::value_type > QtConcurrent:: filtered ( QThreadPool * pool , Iterator begin , Iterator end , KeepFunctor && filterFunction )

調用 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 。若 filterFunction 返迴 true , a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item in sequence . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce , reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

調用 filterFunction once for each item from begin to end . All calls to filterFunction are invoked from the threads taken from the QThreadPool pool 。若 filterFunction 返迴 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 返迴 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 。若 reduceOptions is QtConcurrent::OrderedReduce reduceFunction is called in the order of the original sequence.

另請參閱 並發過濾和過濾縮減 .

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

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

另請參閱 並發映射和映射縮減 .

template <typename Iterator, typename MapFunctor> QFuture < void > QtConcurrent:: map ( Iterator begin , Iterator end , MapFunctor && function )

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

另請參閱 並發映射和映射縮減 .

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

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

另請參閱 並發映射和映射縮減 .

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

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

另請參閱 並發映射和映射縮減 .

template <typename Sequence, typename MapFunctor> QFuture < QtPrivate::MapResultType < Sequence , MapFunctor >> QtConcurrent:: mapped ( Sequence && sequence , MapFunctor && function )

調用 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.

另請參閱 並發映射和映射縮減 .

template <typename Iterator, typename MapFunctor> QFuture < QtPrivate::MapResultType < Iterator , MapFunctor >> QtConcurrent:: mapped ( Iterator begin , Iterator end , MapFunctor && function )

調用 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.

另請參閱 並發映射和映射縮減 .

template <typename Sequence, typename MapFunctor> QFuture < QtPrivate::MapResultType < Sequence , MapFunctor >> QtConcurrent:: mapped ( QThreadPool * pool , Sequence && sequence , MapFunctor && function )

調用 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 。可以使用 QFuture::const_iterator or QFutureIterator to iterate through the results.

另請參閱 並發映射和映射縮減 .

template <typename Iterator, typename MapFunctor> QFuture < QtPrivate::MapResultType < Iterator , MapFunctor >> QtConcurrent:: mapped ( QThreadPool * pool , Iterator begin , Iterator end , MapFunctor && function )

調用 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 。可以使用 QFuture::const_iterator or QFutureIterator to iterate through the results.

另請參閱 並發映射和映射縮減 .

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

調用 mapFunction once for each item in sequence . The return value of each mapFunction 被傳遞給 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 .

另請參閱 並發映射和映射縮減 .

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

調用 mapFunction once for each item from begin to end . The return value of each mapFunction 被傳遞給 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.

注意: QtConcurrent::OrderedReduce results in the ordered reduction.

另請參閱 並發映射和映射縮減 .

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

調用 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 被傳遞給 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 .

另請參閱 並發映射和映射縮減 .

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 = ReduceOptions(UnorderedReduce | SequentialReduce))

調用 mapFunction once for each item in sequence . The return value of each mapFunction 被傳遞給 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 .

另請參閱 並發映射和映射縮減 .

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

調用 mapFunction once for each item from begin to end . The return value of each mapFunction 被傳遞給 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.

注意: QtConcurrent::OrderedReduce results in the ordered reduction.

另請參閱 並發映射和映射縮減 .

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

調用 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 被傳遞給 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.

注意: QtConcurrent::OrderedReduce results in the ordered reduction.

另請參閱 並發映射和映射縮減 .

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 = ReduceOptions(UnorderedReduce | SequentialReduce))

調用 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 被傳遞給 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 .

另請參閱 並發映射和映射縮減 .

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

調用 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 被傳遞給 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.

注意: QtConcurrent::OrderedReduce results in the ordered reduction.

另請參閱 並發映射和映射縮減 .

template <typename T> QFuture < T > QtConcurrent:: run ( 函數 function , ...)

相當於

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

運行 function in a separate thread. The thread is taken from the global QThreadPool 。注意, function may not run immediately; function will only be run once a thread becomes available.

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

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.

run with promise mode function is expected to return void and must take an additional argument of QPromise<T> & 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<T> .

run with promise mode , similar to basic 模式, 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 .

另請參閱 並發運行 (基本模式) , 按 Promise (承諾) 並發運行 ,和 QThreadPool::start ().

template <typename T> QFuture < T > QtConcurrent:: run ( QThreadPool * pool , 函數 function , ...)

調度 function on pool 。注意, function may not run immediately; function will only be run once a thread becomes available.

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

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.

run with promise mode function is expected to return void and must take an additional argument of QPromise<T> & 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<T> .

run with promise mode , similar to basic 模式, 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 .

另請參閱 並發運行 (基本模式) , 按 Promise (承諾) 並發運行 ,和 QThreadPool::start ().

[since 6.0] template <typename Task> QtConcurrent::QTaskBuilder < Task > 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.

該函數在 Qt 6.0 引入。

另請參閱 並發任務 and QtConcurrent::QTaskBuilder .