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_tag; template<class R> state(coroutine_handle<promise_type> h, R&& rr); ~state(); void start() & noexcept; stop_token_type get-stop-token(); // exposition only private: using own-env-t = see below; // exposition only coroutine_handle<promise_type> handle; // exposition only remove_cvref_t<Rcvr> rcvr; // exposition only optional<stop_source_type> source; // exposition only own-env-t own-env; // exposition only Environment environment; // exposition only optional<T> result; // exposition only; present only if is_void_v<T> is false exception_ptr error; // 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 start_scheduler_type(get_start_scheduler(get_env(rcvr))) if that expression is valid and start_scheduler_type() otherwise.
    If neither of these expressions is valid, the program is ill-formed.
Finally, invokes handle.resume().
stop_token_type get-stop-token(); // exposition only
Effects: If same_as<decltype(declval<stop_source_type>().get_token()), decltype(get_
stop_token(get_env(rcvr)))>
is true, returns get_stop_token(get_env(rcvr)).
Otherwise, if source.has_value() is false, initializes the contained value of source such that
  • source->stop_requested() returns get_stop_token(get_env(rcvr))->stop_requested();
    and
  • source->stop_possible() returns get_stop_token(get_env(rcvr))->stop_possible().
Finally, returns source->get_token().
HTTPS · eel.is
← Home