[exec.sched]

# 33 Execution control library [[exec]](./#exec)

## 33.6 Schedulers [exec.sched]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1099)

The [scheduler](#concept:scheduler "33.6 Schedulers [exec.sched]") concept defines
the requirements of a scheduler type ([[exec.async.ops]](exec.async.ops "33.3 Asynchronous operations"))[.](#1.sentence-1)

schedule is a customization point object
that accepts a scheduler[.](#1.sentence-2)

A valid invocation of schedule is a schedule-expression[.](#1.sentence-3)

namespace std::execution {template<class Sch>concept [scheduler](#concept:scheduler "33.6 Schedulers [exec.sched]") =[derived_from](concept.derived#concept:derived_from "18.4.3 Concept derived_­from [concept.derived]")<typename remove_cvref_t<Sch>::scheduler_concept, scheduler_t> &&[*queryable*](exec.queryable.concept#concept:queryable "33.2.2 queryable concept [exec.queryable.concept]")<Sch> &&requires(Sch&& sch) {{ schedule(std::forward<Sch>(sch)) } -> [sender](exec.snd.concepts#concept:sender "33.9.3 Sender concepts [exec.snd.concepts]"); { auto(get_completion_scheduler<set_value_t>( get_env(schedule(std::forward<Sch>(sch))))) }-> [same_as](concept.same#concept:same_as "18.4.2 Concept same_­as [concept.same]")<remove_cvref_t<Sch>>; } &&[equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<remove_cvref_t<Sch>> &&[copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")<remove_cvref_t<Sch>>;}

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1122)

Let Sch be the type of a scheduler and
let Env be the type of an execution environment
for which [sender_in](exec.snd.concepts#concept:sender_in "33.9.3 Sender concepts [exec.snd.concepts]")<schedule_result_t<Sch>, Env> is satisfied[.](#2.sentence-1)

Then [*sender-in-of*](exec.snd.concepts#concept:sender-in-of "33.9.3 Sender concepts [exec.snd.concepts]")<schedule_result_t<Sch>, Env> shall be modeled[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1130)

No operation required by[copyable](concepts.object#concept:copyable "18.6 Object concepts [concepts.object]")<remove_cvref_t<Sch>> and[equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4 Concept equality_­comparable [concept.equalitycomparable]")<remove_cvref_t<Sch>> shall exit via an exception[.](#3.sentence-1)

None of these operations,
nor a scheduler type's schedule function,
shall introduce data races
as a result of potentially concurrent ([[intro.races]](intro.races "6.10.2.2 Data races")) invocations
of those operations from different threads[.](#3.sentence-2)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1141)

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[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1148)

For a given scheduler expression sch,
the expressionget_completion_scheduler<set_value_t>(get_env(schedule(sch))) shall compare equal to sch[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1154)

For a given scheduler expression sch,
if the expression get_domain(sch) is well-formed,
then the expression get_domain(get_env(schedule(sch))) is also well-formed and has the same type[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1160)

A scheduler type's destructor shall not block
pending completion of any receivers
connected to the sender objects returned from schedule[.](#7.sentence-1)

[*Note [1](#note-1)*:

The ability to wait for completion of submitted function objects
can be provided by the associated execution resource of the scheduler[.](#7.sentence-2)

â *end note*]
