-
Francesco Zoffoli authored
Summary: `collectAll` allows to `co_await`s multiple tasks using structured concurrency. Unfortunately `future::collectAny` does not follow the structured concurrency pattern, and detaches the uncompleted operations. This can result in memory errors (the coroutines access data that has already been freed). This diff introduces `coro::collectAny`, which given a number of awaitables it returns the result of the first awaitable to finish, in addition to its index, cancels the remaining operations **and waits for them to complete**. The implementation uses `collectAll` as a building block. The return signature mirrors the one from `future::collectAny`. Reviewed By: yfeldblum, rptynan Differential Revision: D28945040 fbshipit-source-id: 402be03e004d373cbc74821ae8282b1aaf621b2d
b8f35551