4.0 KiB
[task.state]
33 Execution control library [exec]
33.13 Coroutine utilities [exec.coro.util]
33.13.6 execution::task [exec.task]
33.13.6.4 Class template task::state [task.state]
namespace std::execution {template<class T, class Environment>template<receiver Rcvr>class task<T, Environment>::state { // exposition onlypublic:using operation_state_concept = operation_state_t; templatestate(coroutine_handle<promise_type> h, R&& rr); ~state(); void start() & noexcept; private:using own-env-t = see below; // exposition only coroutine_handle<promise_type> handle; // exposition only remove_cvref_t rcvr; // exposition only**own-env-t own-env; // exposition only Environment environment; // exposition only};}
The type own-env-t is Environment::template env_type<decltype(get_env(declval()))> if thatqualified-id is valid and denotes a type, env<> otherwise.
template<class R> state(coroutine_handle<promise_type> h, R&& rr);
Effects: Initializes
-
handle with std::move(h);
-
rcvr with std::forward(rr);
-
own-env with own-env-t(get_env(rcvr)) if that expression is valid and own-env-t() otherwise. If neither of these expressions is valid, the program is ill-formed.
-
environment withEnvironment(own-env) if that expression is valid, otherwise Environment(get_env(rcvr)) if this expression is valid, otherwise Environment(). If neither of these expressions is valid, the program is ill-formed.
~state();
Effects: Equivalent to:if (handle)handle.destroy();
void start() & noexcept;
Effects: Let prom be the object handle.promise().
Associates STATE(prom), RCVR(prom), and SCHED(prom) with *this as follows:
-
STATE(prom) is *this.
-
RCVR(prom) is rcvr.
-
SCHED(prom) is the object initialized with scheduler_type(get_scheduler(get_env(rcvr))) if that expression is valid and scheduler_type() otherwise. If neither of these expressions is valid, the program is ill-formed.
Let st be get_stop_token(get_env(rcvr)).
Initializes prom.token andprom.source such that
prom.token.stop_requested() returnsst.stop_requested();
prom.token.stop_possible() returnsst.stop_possible(); and
for types Fn and Init such that bothinvocable andconstructible_from<Fn, Init> are modeled,stop_token_type::callback_type modelsstoppable-callback-for<Fn, stop_token_type, Init>.
After that invokes handle.resume().