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 only public: using operation_state_concept = operation_state_t; template<class R> state(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> 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​<Rcvr>()))> if that qualified-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<R>(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 with Environment(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 and prom.source such that
  • prom.token.stop_requested() returns st.stop_requested();
  • prom.token.stop_possible() returns st.stop_possible(); and
  • for types Fn and Init such that both invocable<Fn> and constructible_from<Fn, Init> are modeled, stop_token_type​::​callback_type<Fn> models stoppable-callback-for<Fn,​ stop_token_type, Init>.
After that invokes handle.resume().