Schedules several tasks and blocks until all of them are completed. In the process of their successful completion given callback would be called for each of them with the index of the task and the result it returned (if not void). If any of these n tasks throws an exception, this exception will be re-thrown, but only when all tasks are complete. If several tasks throw exceptions one of them will be re-thrown. Callback won't be called for tasks that throw exception.
Declared in <folly/fibers/ForEach.h>
template<
class InputIterator,
class F>
void
forEach(
InputIterator first,
InputIterator last,
F&& f);
| Name | Description |
|---|---|
| first | Beginning of the range of tasks to be scheduled |
| last | End of the range of tasks to be scheduled |
| f | callback to call for each result. In case of each task returning void it should be callable f(size_t id) otherwise should be callable f(size_t id, Result) |