This topic has not yet been rated - Rate this topic

parallel_for_each Function

parallel_for_each applies a specified function to each element within a range, in parallel. It is semantically equivalent to the for_each function in the std namespace, except that iteration over the elements is performed in parallel, and the order of iteration is unspecified. The argument _Func must support a function call operator of the form operator()(T) where the parameter T is the item type of the container being iterated over.

template <
   typename _Iterator,
   typename _Function
>
void parallel_for_each(
   _Iterator_First,
   _Iterator_Last,
   const _Function& _Func
);
_Iterator

The type of the iterator being used to iterate over the container.

_Function

The type of the function that will be applied to each element within the range.

_First

An iterator addressing the position of the first element to be included in parallel iteration.

_Last

An iterator addressing the position one past the final element to be included in parallel iteration.

_Func

A user-defined function object that is applied to each element in the range.

For more information, see Parallel Algorithms.

Header: ppl.h

Namespace: Concurrency

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
parallel_for_each cause memory leak !
It is a simple code demo, as following: $0static void ParallelForEachMemoryLeakTest()$0 $0{$0 $0vector<int> test(10000);int t = 90;$0 $0$0 $0       parallel_for_each(test.begin(),test.end(),|$0          [](int i)$0           {$0              // Do nothing$0            });$0 $0}$0 When this function is called, memory leak issue happens.$0 Is it a bug of PPL? $0 $0$0 $0$0 $0$0 $0$0