3.3 KiB
[exec.with.awaitable.senders]
33 Execution control library [exec]
33.13 Coroutine utilities [exec.coro.util]
33.13.2 execution::with_awaitable_senders [exec.with.awaitable.senders]
with_awaitable_senders, when used as the base class of a coroutine promise type, makes senders awaitable in that coroutine type.
In addition, it provides a default implementation of unhandled_stopped such that if a sender completes by calling set_stopped, it is treated as if an uncatchable "stopped" exception were thrown from the await-expression.
[Note 1:
The coroutine is never resumed, and the unhandled_stopped of the coroutine caller's promise type is called.
â end note]
namespace std::execution {template<class-type Promise>struct with_awaitable_senders {templaterequires (<OtherPromise, void>)void set_continuation(coroutine_handle h) noexcept;
coroutine_handle<> continuation() const noexcept { return continuation; } coroutine_handle<> unhandled_stopped() noexcept {return stopped-handler(continuation.address()); }templatesee below await_transform(Value&& value); private:noreturn static coroutine_handle<>default-unhandled-stopped(void*) noexcept { // exposition only terminate(); } coroutine_handle<> continuation{}; // exposition only coroutine_handle<> (stopped-handler)(void) noexcept = // exposition only&default-unhandled-stopped; };}
template<class OtherPromise> requires (<OtherPromise, void>) void set_continuation(coroutine_handle<OtherPromise> h) noexcept;
Effects: Equivalent to:continuation = h;if constexpr ( requires(OtherPromise& other) { other.unhandled_stopped(); } ) {stopped-handler = [](void* p) noexcept -> coroutine_handle<> {return coroutine_handle::from_address(p).promise().unhandled_stopped(); };} else {stopped-handler = &default-unhandled-stopped;}
template<class Value> call-result-t<as_awaitable_t, Value, Promise&> await_transform(Value&& value);
Effects: Equivalent to:return as_awaitable(std::forward(value), static_cast<Promise&>(*this));