2 out of 2 rated this helpful - Rate this topic

parallel_for Function

parallel_for iterates over a range of indices and executes a user-supplied function at each iteration, in parallel.

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
);
_Index_type

The type of the index being used for the iteration. _Index_type must be an integral type.

_Function

The type of the function that will be executed at each iteration.

_First

The first index to be included in the iteration.

_Last

The index one past the last index to be included in the iteration.

_Step

The value by which to step when iterating from _First to _Last. The step must be positive. invalid_argument is thrown if the step is less than 1.

_Func

The function to be executed at each iteration. This may be a lambda expression, a function pointer, or any object that supports a version of the function call operator with the signature void operator()(_Index_type).

For more information, see Parallel Algorithms.

Header: ppl.h

Namespace: Concurrency

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
unsigned vs signed
Note that both arguments (from and to) must be of the same type. This means you have to cast uint or int if you had one of each.