33 Execution control library [exec]

33.6 Schedulers [exec.sched]

The scheduler concept defines the requirements of a scheduler type ([exec.async.ops]).
schedule is a customization point object that accepts a scheduler.
A valid invocation of schedule is a schedule-expression.
namespace std::execution { template<class Sch> concept scheduler = derived_from<typename remove_cvref_t<Sch>::scheduler_concept, scheduler_tag> && queryable<Sch> && requires(Sch&& sch) { { schedule(std::forward<Sch>(sch)) } -> sender; { get_forward_progress_guarantee(sch) } -> same_as<forward_progress_guarantee>; } && equality_comparable<remove_cvref_t<Sch>> && copyable<remove_cvref_t<Sch>>; }
Let Sch be the type of a scheduler and let Env be the type of an execution environment for which sender_in<schedule_result_t<Sch>, Env> is satisfied.
Then sender-in-of<schedule_result_t<Sch>, Env> shall be modeled.
No operation required by copyable<remove_cvref_t<Sch>> and equality_comparable<remove_cvref_t<Sch>> shall exit via an exception.
None of these operations, nor a scheduler type's schedule function, shall introduce data races as a result of potentially concurrent ([intro.races]) invocations of those operations from different threads.
For any two values sch1 and sch2 of some scheduler type Sch, sch1 == sch2 shall return true only if both sch1 and sch2 share the same associated execution resource.
For a given scheduler expression sch, if the expression get_completion_scheduler<set_value_t>(get_env(schedule(sch))) is well-formed, it shall compare equal to sch.
For a given scheduler expression sch, type T, and pack of subexpressions envs, the following expressions are either both ill-formed, or both well-formed with the same type:
  • get_completion_domain<T>(sch, envs...)
  • get_completion_domain<T>(get_env(schedule(sch)), envs...)
Likewise, the following expressions are either both ill-formed, or both well-formed with the same type and value:
  • get_completion_scheduler<T>(sch, envs...)
  • get_completion_scheduler<T>(get_env(schedule(sch)), envs...)
A scheduler type's destructor shall not block pending completion of any receivers connected to the sender objects returned from schedule.
The exposition-only infallible-scheduler concept defines the requirements of a scheduler type whose schedule asynchronous operation can only complete with set_value unless stop can be requested: template<class Sch, class Env> concept infallible-scheduler = scheduler<Sch> && (same_as<completion_signatures<set_value_t()>, completion_signatures_of_t<decltype(schedule(declval<Sch>())), Env>> || (!unstoppable_token<stop_token_of_t<Env>> && (same_as<completion_signatures<set_value_t(), set_stopped_t()>, completion_signatures_of_t<decltype(schedule(declval<Sch>())), Env>> || same_as<completion_signatures<set_stopped_t(), set_value_t()>, completion_signatures_of_t<decltype(schedule(declval<Sch>())), Env>>)));