Add folly::coro::collectAll[Try]Range()
Summary: Add functions for concurrently awaiting a collection of SemiAwaitable objects. * `folly::coro::collectAllRange()` takes an InputRange of SemiAwaitable objects and concurrently awaits them, producing a `std::vector` of the results. This will throw an exception if any of the input operations failed with an exception. * `folly::coro::collectAllTryRange()` takes an InputRange of SemiAwaitable objects and concurrently awaits them, producing a `std::vector<folly::Try<T>>` containing the results. Failure of individual operations can be determined by inspecting the corresponding `Try` value. This diff also refactors the existing implementations of `folly::coro::collectAll()` to make use of a new `Barrier` and `BarrierTask` implementation detail rather than using `DetachedInlineTask`, `Baton` and an atomic counter. This allows delaying the start of the child corouines until after all coroutines have been created which was necessary for cases where we didn't know the number of elements in the input range to allow storage for the results to be allocated in a vector before the tasks start producing results. Reviewed By: andriigrynenko Differential Revision: D14430147 fbshipit-source-id: 5ba4b7cdc3c9b65d1736f14a2d39f7beb6cb82b0
Showing
This diff is collapsed.
Please register or sign in to comment