135 lines
5.6 KiB
Markdown
135 lines
5.6 KiB
Markdown
[exec.factories]
|
||
|
||
# 33 Execution control library [[exec]](./#exec)
|
||
|
||
## 33.9 Senders [[exec.snd]](exec.snd#exec.factories)
|
||
|
||
### 33.9.11 Sender factories [exec.factories]
|
||
|
||
#### [33.9.11.1](#exec.schedule) execution::schedule [[exec.schedule]](exec.schedule)
|
||
|
||
[1](#exec.schedule-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2877)
|
||
|
||
schedule obtains a schedule sender ([[exec.async.ops]](exec.async.ops "33.3 Asynchronous operations"))
|
||
from a scheduler[.](#exec.schedule-1.sentence-1)
|
||
|
||
[2](#exec.schedule-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2881)
|
||
|
||
The name schedule denotes a customization point object[.](#exec.schedule-2.sentence-1)
|
||
|
||
For a subexpression sch,
|
||
the expression schedule(sch) is expression-equivalent tosch.schedule()[.](#exec.schedule-2.sentence-2)
|
||
|
||
[3](#exec.schedule-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2887)
|
||
|
||
*Mandates*: The type of sch.schedule() satisfies [sender](exec.snd.concepts#concept:sender "33.9.3 Sender concepts [exec.snd.concepts]")[.](#exec.schedule-3.sentence-1)
|
||
|
||
[4](#exec.schedule-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2891)
|
||
|
||
If the expressionget_completion_scheduler<set_value_t>(get_env(sch.schedule())) == sch is ill-formed or evaluates to false,
|
||
the behavior of calling schedule(sch) is undefined[.](#exec.schedule-4.sentence-1)
|
||
|
||
#### [33.9.11.2](#exec.just) execution::just, execution::just_error, execution::just_stopped [[exec.just]](exec.just)
|
||
|
||
[1](#exec.just-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2901)
|
||
|
||
just, just_error, and just_stopped are sender factories
|
||
whose asynchronous operations complete synchronously in their start operation
|
||
with a value completion operation,
|
||
an error completion operation, or
|
||
a stopped completion operation, respectively[.](#exec.just-1.sentence-1)
|
||
|
||
[2](#exec.just-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2908)
|
||
|
||
The names just, just_error, and just_stopped denote
|
||
customization point objects[.](#exec.just-2.sentence-1)
|
||
|
||
Let *just-cpo* be one ofjust, just_error, or just_stopped[.](#exec.just-2.sentence-2)
|
||
|
||
For a pack of subexpressions ts,
|
||
let Ts be the pack of types decltype((ts))[.](#exec.just-2.sentence-3)
|
||
|
||
The expression *just-cpo*(ts...) is ill-formed if
|
||
|
||
- [(2.1)](#exec.just-2.1)
|
||
|
||
([*movable-value*](exec.general#concept:movable-value "33.1 General [exec.general]")<Ts> &&...) is false, or
|
||
|
||
- [(2.2)](#exec.just-2.2)
|
||
|
||
*just-cpo* is just_error andsizeof...(ts) == 1 is false, or
|
||
|
||
- [(2.3)](#exec.just-2.3)
|
||
|
||
*just-cpo* is just_stopped andsizeof...(ts) == 0 is false[.](#exec.just-2.sentence-4)
|
||
|
||
Otherwise, it is expression-equivalent to*make-sender*(*just-cpo*, *product-type*{ts...})[.](#exec.just-2.sentence-5)
|
||
|
||
For just, just_error, and just_stopped,
|
||
let *set-cpo* beset_value, set_error, and set_stopped, respectively[.](#exec.just-2.sentence-6)
|
||
|
||
The exposition-only class template *impls-for* ([[exec.snd.expos]](exec.snd.expos "33.9.2 Exposition-only entities"))
|
||
is specialized for *just-cpo* as follows:namespace std::execution {template<>struct *impls-for*<*decayed-typeof*<*just-cpo*>> : *default-impls* {static constexpr auto *start* =[](auto& state, auto& rcvr) noexcept -> void {auto& [...ts] = state; *set-cpo*(std::move(rcvr), std::move(ts)...); }; };}
|
||
|
||
#### [33.9.11.3](#exec.read.env) execution::read_env [[exec.read.env]](exec.read.env)
|
||
|
||
[1](#exec.read.env-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2950)
|
||
|
||
read_env is a sender factory for a sender
|
||
whose asynchronous operation completes synchronously in its start operation
|
||
with a value completion result equal to
|
||
a value read from the receiver's associated environment[.](#exec.read.env-1.sentence-1)
|
||
|
||
[2](#exec.read.env-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2956)
|
||
|
||
read_env is a customization point object[.](#exec.read.env-2.sentence-1)
|
||
|
||
For some query object q,
|
||
the expression read_env(q) is expression-equivalent to*make-sender*(read_env, q)[.](#exec.read.env-2.sentence-2)
|
||
|
||
[3](#exec.read.env-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2962)
|
||
|
||
The exposition-only class template *impls-for* ([[exec.snd.expos]](exec.snd.expos "33.9.2 Exposition-only entities"))
|
||
is specialized for read_env as follows:
|
||
|
||
[ð](#lib:impls-for%3cdecayed-typeof%3cread_env%3e%3e)
|
||
|
||
namespace std::execution {template<>struct *impls-for*<*decayed-typeof*<read_env>> : *default-impls* {static constexpr auto start =[](auto query, auto& rcvr) noexcept -> void {*TRY-SET-VALUE*(rcvr, query(get_env(rcvr))); }; }; template<class Sndr, class Env>static consteval void *check-types*();}
|
||
|
||
[ð](#lib:check-types,impls-for%3cdecayed-typeof%3cread_env%3e%3e)
|
||
|
||
`template<class Sndr, class Env>
|
||
static consteval void check-types();
|
||
`
|
||
|
||
[4](#exec.read.env-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2988)
|
||
|
||
Let Q be decay_t<*data-type*<Sndr>>[.](#exec.read.env-4.sentence-1)
|
||
|
||
[5](#exec.read.env-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L2991)
|
||
|
||
*Throws*: An exception of an unspecified type derived from exception if
|
||
the expression Q()(env) is ill-formed or has type void, whereenv is an lvalue subexpression whose type is Env[.](#exec.read.env-5.sentence-1)
|