103 lines
6.4 KiB
Markdown
103 lines
6.4 KiB
Markdown
[exec.recv]
|
||
|
||
# 33 Execution control library [[exec]](./#exec)
|
||
|
||
## 33.7 Receivers [exec.recv]
|
||
|
||
### [33.7.1](#concepts) Receiver concepts [[exec.recv.concepts]](exec.recv.concepts)
|
||
|
||
[1](#concepts-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1173)
|
||
|
||
A receiver represents the continuation of an asynchronous operation[.](#concepts-1.sentence-1)
|
||
|
||
The [receiver](#concept:receiver "33.7.1 Receiver concepts [exec.recv.concepts]") concept defines
|
||
the requirements for a receiver type ([[exec.async.ops]](exec.async.ops "33.3 Asynchronous operations"))[.](#concepts-1.sentence-2)
|
||
|
||
The [receiver_of](#concept:receiver_of "33.7.1 Receiver concepts [exec.recv.concepts]") concept defines
|
||
the requirements for a receiver type that is usable as
|
||
the first argument of a set of completion operations
|
||
corresponding to a set of completion signatures[.](#concepts-1.sentence-3)
|
||
|
||
The get_env customization point object is used to access
|
||
a receiver's associated environment[.](#concepts-1.sentence-4)
|
||
|
||
namespace std::execution {template<class Rcvr>concept [receiver](#concept:receiver "33.7.1 Receiver concepts [exec.recv.concepts]") =[derived_from](concept.derived#concept:derived_from "18.4.3 Concept derived_from [concept.derived]")<typename remove_cvref_t<Rcvr>::receiver_concept, receiver_t> &&requires(const remove_cvref_t<Rcvr>& rcvr) {{ get_env(rcvr) } -> [*queryable*](exec.queryable.concept#concept:queryable "33.2.2 queryable concept [exec.queryable.concept]"); } &&[move_constructible](concept.moveconstructible#concept:move_constructible "18.4.13 Concept move_constructible [concept.moveconstructible]")<remove_cvref_t<Rcvr>> && // rvalues are movable, and[constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_from [concept.constructible]")<remove_cvref_t<Rcvr>, Rcvr>; // lvalues are copyabletemplate<class Signature, class Rcvr>concept [*valid-completion-for*](#concept:valid-completion-for "33.7.1 Receiver concepts [exec.recv.concepts]") = // *exposition only*requires (Signature* sig) {[]<class Tag, class... Args>(Tag(*)(Args...))requires [*callable*](functional.syn#concept:callable "22.10.2 Header <functional> synopsis [functional.syn]")<Tag, remove_cvref_t<Rcvr>, Args...>{}(sig); }; template<class Rcvr, class Completions>concept [*has-completions*](#concept:has-completions "33.7.1 Receiver concepts [exec.recv.concepts]") = // *exposition only*requires (Completions* completions) {[]<[*valid-completion-for*](#concept:valid-completion-for "33.7.1 Receiver concepts [exec.recv.concepts]")<Rcvr>...Sigs>(completion_signatures<Sigs...>*){}(completions); }; template<class Rcvr, class Completions>concept [receiver_of](#concept:receiver_of "33.7.1 Receiver concepts [exec.recv.concepts]") =[receiver](#concept:receiver "33.7.1 Receiver concepts [exec.recv.concepts]")<Rcvr> && [*has-completions*](#concept:has-completions "33.7.1 Receiver concepts [exec.recv.concepts]")<Rcvr, Completions>;}
|
||
|
||
[2](#concepts-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1215)
|
||
|
||
Class types that are marked final do not model the [receiver](#concept:receiver "33.7.1 Receiver concepts [exec.recv.concepts]") concept[.](#concepts-2.sentence-1)
|
||
|
||
[3](#concepts-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1218)
|
||
|
||
Let rcvr be a receiver and
|
||
let op_state be an operation state associated with
|
||
an asynchronous operation created by connecting rcvr with a sender[.](#concepts-3.sentence-1)
|
||
|
||
Let token be a stop token equal toget_stop_token(get_env(rcvr))[.](#concepts-3.sentence-2)
|
||
|
||
token shall remain valid
|
||
for the duration of the asynchronous operation's lifetime ([[exec.async.ops]](exec.async.ops "33.3 Asynchronous operations"))[.](#concepts-3.sentence-3)
|
||
|
||
[*Note [1](#concepts-note-1)*:
|
||
|
||
This means that, unless it knows about further guarantees
|
||
provided by the type of rcvr,
|
||
the implementation of op_state cannot use token after it executes a completion operation[.](#concepts-3.sentence-4)
|
||
|
||
This also implies that any stop callbacks registered on token
|
||
must be destroyed before the invocation of the completion operation[.](#concepts-3.sentence-5)
|
||
|
||
â *end note*]
|
||
|
||
### [33.7.2](#exec.set.value) execution::set_value [[exec.set.value]](exec.set.value)
|
||
|
||
[1](#exec.set.value-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1237)
|
||
|
||
set_value is a value completion function ([[exec.async.ops]](exec.async.ops "33.3 Asynchronous operations"))[.](#exec.set.value-1.sentence-1)
|
||
|
||
Its associated completion tag is set_value_t[.](#exec.set.value-1.sentence-2)
|
||
|
||
The expression set_value(rcvr, vs...) for a subexpression rcvr and
|
||
pack of subexpressions vs is ill-formed
|
||
if rcvr is an lvalue or an rvalue of const type[.](#exec.set.value-1.sentence-3)
|
||
|
||
Otherwise, it is expression-equivalent to*MANDATE-NOTHROW*(rcvr.set_value(vs...))[.](#exec.set.value-1.sentence-4)
|
||
|
||
### [33.7.3](#exec.set.error) execution::set_error [[exec.set.error]](exec.set.error)
|
||
|
||
[1](#exec.set.error-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1249)
|
||
|
||
set_error is an error completion function ([[exec.async.ops]](exec.async.ops "33.3 Asynchronous operations"))[.](#exec.set.error-1.sentence-1)
|
||
|
||
Its associated completion tag is set_error_t[.](#exec.set.error-1.sentence-2)
|
||
|
||
The expression set_error(rcvr, err) for some subexpressions rcvr and err is ill-formed
|
||
if rcvr is an lvalue or an rvalue of const type[.](#exec.set.error-1.sentence-3)
|
||
|
||
Otherwise, it is expression-equivalent to*MANDATE-NOTHROW*(rcvr.set_error(err))[.](#exec.set.error-1.sentence-4)
|
||
|
||
### [33.7.4](#exec.set.stopped) execution::set_stopped [[exec.set.stopped]](exec.set.stopped)
|
||
|
||
[1](#exec.set.stopped-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L1260)
|
||
|
||
set_stopped is a stopped completion function ([[exec.async.ops]](exec.async.ops "33.3 Asynchronous operations"))[.](#exec.set.stopped-1.sentence-1)
|
||
|
||
Its associated completion tag is set_stopped_t[.](#exec.set.stopped-1.sentence-2)
|
||
|
||
The expression set_stopped(rcvr) for a subexpression rcvr is ill-formed
|
||
if rcvr is an lvalue or an rvalue of const type[.](#exec.set.stopped-1.sentence-3)
|
||
|
||
Otherwise, it is expression-equivalent to*MANDATE-NOTHROW*(rcvr.set_stopped())[.](#exec.set.stopped-1.sentence-4)
|