2 * Copyright 2015 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 namespace folly { namespace fibers {
21 * Schedules several tasks and blocks until all of them are completed.
22 * In the process of their successfull completion given callback would be called
23 * for each of them with the index of the task and the result it returned (if
25 * If any of these n tasks throws an exception, this exception will be
26 * re-thrown, but only when all tasks are complete. If several tasks throw
27 * exceptions one of them will be re-thrown. Callback won't be called for
28 * tasks that throw exception.
30 * @param first Range of tasks to be scheduled
32 * @param F callback to call for each result.
33 * In case of each task returning void it should be callable
35 * otherwise should be callable
36 * F(size_t id, Result)
38 template <class InputIterator, class F>
39 inline void forEach(InputIterator first, InputIterator last, F&& f);
43 #include <folly/experimental/fibers/ForEach-inl.h>