parallel_for 函式
parallel_for 會逐一查看某個範圍的索引,並以平行方式在每個反覆項目執行使用者提供函式。
template <
typename _Index_type,
typename _Function,
typename _Partitioner
>
void parallel_for(
_Index_type_First,
_Index_type_Last,
_Index_type_Step,
const _Function& _Func,
_Partitioner&& _Part
);
template <
typename _Index_type,
typename _Function
>
void parallel_for(
_Index_type_First,
_Index_type_Last,
_Index_type_Step,
const _Function& _Func
);
template <
typename _Index_type,
typename _Function
>
void parallel_for(
_Index_type_First,
_Index_type_Last,
const _Function& _Func,
const auto_partitioner& _Part = auto_partitioner()
);
template <
typename _Index_type,
typename _Function
>
void parallel_for(
_Index_type_First,
_Index_type_Last,
const _Function& _Func,
const static_partitioner& _Part
);
template <
typename _Index_type,
typename _Function
>
void parallel_for(
_Index_type_First,
_Index_type_Last,
const _Function& _Func,
const simple_partitioner& _Part
);
template <
typename _Index_type,
typename _Function
>
void parallel_for(
_Index_type_First,
_Index_type_Last,
const _Function& _Func,
affinity_partitioner& _Part
);
參數
_Index_type
要用於反覆運算的索引的型別。_Function
將在每個反覆項目執行的函式的型別。_Partitioner
可用來分割提供的範圍的 partitioner 型別。_First
要包含在反覆項目中的第一個索引。_Last
要包含在反覆項目中的最後一個索引旁的索引。_Step
從 _First 逐步執行到 _Last 時逐步執行的值。 步驟必須是正數。 如果步驟少於 1,則會擲回 invalid_argument。_Func
要在每個反覆項目執行的函式。 這可能是 Lambda 運算式、函式指標或支援函式呼叫運算子與簽章 void operator()(_Index_type**)** 版本的任何物件。_Part
Partitioner 物件參考。 引數可為任一constauto_partitioner&, conststatic_partitioner&, constsimple_partitioner**&或 affinity_partitioner&**如果 affinity_partitioner 物件,則參照來源必須非常值 (l-value) 的參考,如此演算法可以儲存的未來的迴圈,以重複使用的狀態。
備註
如需詳細資訊,請參閱 平行演算法。
需求
標頭: ppl.h
Namespace: 並行存取