Consistency in namespace-closing comments
[folly.git] / folly / fibers / ForEach.h
1 /*
2  * Copyright 2017 Facebook, Inc.
3  *
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
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #pragma once
17
18 namespace folly {
19 namespace fibers {
20
21 /**
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
25  * not void).
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.
30  *
31  * @param first  Range of tasks to be scheduled
32  * @param last
33  * @param F      callback to call for each result.
34  *               In case of each task returning void it should be callable
35  *                  F(size_t id)
36  *               otherwise should be callable
37  *                  F(size_t id, Result)
38  */
39 template <class InputIterator, class F>
40 inline void forEach(InputIterator first, InputIterator last, F&& f);
41 } // namespace fibers
42 } // namespace folly
43
44 #include <folly/fibers/ForEach-inl.h>