MCPcopy Create free account
hub / github.com/apache/arrow / ParallelForAsync

Function ParallelForAsync

cpp/src/arrow/util/parallel.h:51–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49template <class FUNCTION, typename T,
50 typename R = typename internal::call_traits::return_type<FUNCTION>::ValueType>
51Future<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,

Callers 1

OptionalParallelForAsyncFunction · 0.85

Calls 6

GetCpuThreadPoolFunction · 0.85
UnwrapOrRaiseFunction · 0.85
ThenMethod · 0.80
AllFunction · 0.70
ARROW_ASSIGN_OR_RAISEFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected