6.9 KiB
[exec.task.scheduler]
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 onlytemplate<receiver R>class state; // exposition onlypublic:using scheduler_concept = scheduler_t; template<class Sch, class Allocator = allocator>requires (<task_scheduler, remove_cvref_t>)&& schedulerexplicit task_scheduler(Sch&& sch, Allocator alloc = {}); ts-sender schedule(); friend bool operator==(const task_scheduler& lhs, const task_scheduler& rhs)noexcept; templaterequires (
<task_scheduler, Sch>)&& schedulerfriend bool operator==(const task_scheduler& lhs, const Sch& rhs) noexcept; private: shared_ptr sch_; // exposition only};}
task_scheduler is a class that modelsscheduler ([exec.sched]).
Given an object s of type task_scheduler, letSCHED(s) be the object owned by s.sch_.
template<class Sch, class Allocator = allocator<void>> requires(<task_scheduler, remove_cvref_t<Sch>>) && [scheduler](exec.sched#concept:scheduler "33.6 Schedulers [exec.sched]")<Sch> explicit task_scheduler(Sch&& sch, Allocator alloc = {});
Effects: Initialize sch_ withallocate_shared<remove_cvref_t>(alloc, std::forward(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 orstate 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 (<task_scheduler, Sch>) && [scheduler](exec.sched#concept:scheduler "33.6 Schedulers [exec.sched]")<Sch> bool operator==(const task_scheduler& lhs, const Sch& rhs) noexcept;
Returns: false if the type of SCHED(lhs) is not Sch, otherwise SCHED(lhs) == rhs.
namespace std::execution {class task_scheduler::ts-sender { // exposition onlypublic:using sender_concept = sender_t; template<receiver Rcvr>state connect(Rcvr&& rcvr); };}ts-sender is an exposition-only class that modelssender ([exec.snd]) and for whichcompletion_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 bysndr or an object move constructed from it.
template<[receiver](exec.recv.concepts#concept:receiver "33.7.1 Receiver concepts [exec.recv.concepts]") 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 containing an operation state object initialized with connect(SENDER(*this), std::move(r)).
namespace std::execution {template<receiver R>class task_scheduler::state { // exposition onlypublic: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.