| 49 | template <class FUNCTION, typename T, |
| 50 | typename R = typename internal::call_traits::return_type<FUNCTION>::ValueType> |
| 51 | Future<std::vector<R>> ParallelForAsync(std::vector<T> inputs, FUNCTION&& func, |
| 52 | Executor* executor = internal::GetCpuThreadPool(), |
| 53 | TaskHints hints = TaskHints{}) { |
| 54 | std::vector<Future<R>> futures(inputs.size()); |
| 55 | for (size_t i = 0; i < inputs.size(); ++i) { |
| 56 | ARROW_ASSIGN_OR_RAISE(futures[i], |
| 57 | executor->Submit(hints, func, i, std::move(inputs[i]))); |
| 58 | } |
| 59 | return All(std::move(futures)) |
| 60 | .Then([](const std::vector<Result<R>>& results) -> Result<std::vector<R>> { |
| 61 | return UnwrapOrRaise(results); |
| 62 | }); |
| 63 | } |
| 64 | |
| 65 | // A parallelizer that takes a `Status(int)` function and calls it with |
| 66 | // arguments between 0 and `num_tasks - 1`, in sequence or in parallel, |
no test coverage detected