2 * Copyright 2016 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.
22 * Schedules several tasks and blocks until all of them are completed.
23 * In the process of their successfull completion given callback would be called
24 * for each of them with the index of the task and the result it returned (if
26 * If any of these n tasks throws an exception, this exception will be
27 * re-thrown, but only when all tasks are complete. If several tasks throw
28 * exceptions one of them will be re-thrown. Callback won't be called for
29 * tasks that throw exception.
31 * @param first Range of tasks to be scheduled
33 * @param F callback to call for each result.
34 * In case of each task returning void it should be callable
36 * otherwise should be callable
37 * F(size_t id, Result)
39 template <class InputIterator, class F>
40 inline void forEach(InputIterator first, InputIterator last, F&& f);
44 #include <folly/fibers/ForEach-inl.h>