tmc::spawn_tuple()#
spawn_tuple() wraps multiple awaitables into a single awaitable, that completes when all of the wrapped awaitables complete.
The wrapped awaitables will be executed concurrently.
Each element of the awaitable parameter pack (or tuple parameter) will return its value to the the corresponding element in the result tuple.
If the result type of a particular awaitable parameter would be void, its element in the result tuple will be a std::monostate instead.
If the result type of a particular awaitable parameter is not default-constructible, its element in the result tuple will be a std::optional<Result>.
spawn_tuple supports HALO if it is awaited directly as a prvalue. See HALO for details.
Awaitable Customizations#
The resulting awaitable supports these Awaitable Customizations:
run_on(),
resume_on(),
with_priority(),
co_await,
fork(),
detach().
Receiving Results As They Complete#
To receive each result as soon as it becomes ready - rather than waiting for the whole group to complete - use tmc::mux_tuple. It multiplexes a set of differently-typed awaitables, returns the index of each one as it completes, and additionally lets you re-arm a completed slot with a new awaitable. mux_tuple replaces the former .result_each() execution mode.
API Reference#
-
template<typename ...Awaitable>
aw_spawn_tuple<tmc::detail::forward_awaitable<Awaitable>...> tmc::spawn_tuple(Awaitable&&... Awaitables)# Spawns multiple awaitables and returns an awaiter that allows you to await all of the results. These awaitables may have different return types, and the results will be returned in a tuple. If void-returning awaitable is submitted, its result type will be replaced with std::monostate in the tuple.
Does not support non-awaitable types (such as regular functors).
-
template<typename ...Awaitable>
aw_spawn_tuple<Awaitable...> tmc::spawn_tuple(std::tuple<Awaitable...> &&Awaitables)# Spawns multiple awaitables and returns an awaiter that allows you to await all of the results. These awaitables may have different return types, and the results will be returned in a tuple. If a void-returning awaitable is submitted, its result type will be replaced with std::monostate in the tuple.
Does not support non-awaitable types (such as regular functors).