Files
2025-10-25 03:02:53 +03:00

79 lines
4.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[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.6Schedulers[exec.sched]") concept defines
the requirements of a scheduler type ([[exec.async.ops]](exec.async.ops "33.3Asynchronous 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.6Schedulers[exec.sched]") =[derived_from](concept.derived#concept:derived_from "18.4.3Concept derived_­from[concept.derived]")<typename remove_cvref_t<Sch>::scheduler_concept, scheduler_t> &&[*queryable*](exec.queryable.concept#concept:queryable "33.2.2queryable concept[exec.queryable.concept]")<Sch> &&requires(Sch&& sch) {{ schedule(std::forward<Sch>(sch)) } -> [sender](exec.snd.concepts#concept:sender "33.9.3Sender 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.2Concept same_­as[concept.same]")<remove_cvref_t<Sch>>; } &&[equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4Concept equality_­comparable[concept.equalitycomparable]")<remove_cvref_t<Sch>> &&[copyable](concepts.object#concept:copyable "18.6Object 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.3Sender 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.3Sender 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.6Object concepts[concepts.object]")<remove_cvref_t<Sch>> and[equality_comparable](concept.equalitycomparable#concept:equality_comparable "18.5.4Concept 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.2Data 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*]