33 Execution control library [exec]

33.13 Coroutine utilities [exec.coro.util]

33.13.5 execution​::​task_scheduler [exec.task.scheduler]

namespace std::execution { class task_scheduler { class ts-sender; // exposition only template<receiver R> class state; // exposition only public: using scheduler_concept = scheduler_t; template<class Sch, class Allocator = allocator<void>> requires (!same_as<task_scheduler, remove_cvref_t<Sch>>) && scheduler<Sch> explicit task_scheduler(Sch&& sch, Allocator alloc = {}); ts-sender schedule(); friend bool operator==(const task_scheduler& lhs, const task_scheduler& rhs) noexcept; template<class Sch> requires (!same_as<task_scheduler, Sch>) && scheduler<Sch> friend bool operator==(const task_scheduler& lhs, const Sch& rhs) noexcept; private: shared_ptr<void> sch_; // exposition only }; }
task_scheduler is a class that models scheduler ([exec.sched]).
Given an object s of type task_scheduler, let SCHED(s) be the object owned by s.sch_.
template<class Sch, class Allocator = allocator<void>> requires(!same_as<task_scheduler, remove_cvref_t<Sch>>) && scheduler<Sch> explicit task_scheduler(Sch&& sch, Allocator alloc = {});
Effects: Initialize sch_ with allocate_shared<remove_cvref_t<Sch>>(alloc,​ std​::​forward<Sch>(sch)).
Recommended practice: Implementations should avoid the use of dynamically allocated memory for small scheduler objects.
Remarks: Any allocations performed by construction of ts-sender or state objects resulting from calls on *this are performed using a copy of alloc.
ts-sender schedule();
Effects: Returns an object of type ts-sender containing a sender initialized with schedule(SCHED(*this)).
bool operator==(const task_scheduler& lhs, const task_scheduler& rhs) noexcept;
Effects: Equivalent to: return lhs == SCHED(rhs);
template<class Sch> requires (!same_as<task_scheduler, Sch>) && scheduler<Sch> bool operator==(const task_scheduler& lhs, const Sch& rhs) noexcept;
Returns: false if type of SCHED(lhs) is not Sch, otherwise SCHED(lhs) == rhs;
namespace std::execution { class task_scheduler::ts-sender { // exposition only public: using sender_concept = sender_t; template<receiver Rcvr> state<Rcvr> connect(Rcvr&& rcvr); }; } ts-sender is an exposition-only class that models sender ([exec.snd]) and for which completion_signatures_of_t<ts-sender> denotes: completion_signatures< set_value_t(), set_error_t(error_code), set_error_t(exception_ptr), set_stopped_t()>
Let sch be an object of type task_scheduler and let sndr be an object of type ts-sender obtained from schedule(sch).
Then get_completion_scheduler<set_value_t>(get_env(sndr)) == sch is true.
The object SENDER(sndr) is the sender object contained by sndr or an object move constructed from it.
template<receiver Rcvr> state<Rcvr> connect(Rcvr&& rcvr);
Effects: Let r be an object of a type that models receiver and whose completion handlers result in invoking the corresponding completion handlers of rcvr or copy thereof.
Returns an object of type state<Rcvr> containing an operation state object initialized with connect(SENDER(*this), std​::​move(r)).
namespace std::execution { template<receiver R> class task_scheduler::state { // exposition only public: using operation_state_concept = operation_state_t; void start() & noexcept; }; } state is an exposition-only class template whose specializations model operation_state ([exec.opstate]).
void start() & noexcept;
Effects: Equivalent to start(st) where st is the operation state object contained by *this.