|
922 | 922 |
|
923 | 923 | \pnum
|
924 | 924 | The \libconcept{scheduler} concept defines
|
925 |
| -the requirements of a scheduler type\iref{async.ops}. |
| 925 | +the requirements of a scheduler type\iref{exec.async.ops}. |
926 | 926 | \tcode{schedule} is a customization point object
|
927 | 927 | that accepts a scheduler.
|
928 | 928 | A valid invocation of \tcode{schedule} is a schedule-expression.
|
|
998 | 998 |
|
999 | 999 | \pnum
|
1000 | 1000 | A receiver represents the continuation of an asynchronous operation.
|
1001 |
| -The \libconcept{receiver} concept defines the requirements for a receiver type ([async.ops]). The receiver_of 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. The get_env customization point object is used to access a receiver’s associated environment. |
| 1001 | +The \libconcept{receiver} concept defines |
| 1002 | +the requirements for a receiver type\iref{exec.async.ops}. |
| 1003 | +The \libconcept{receiver_of} concept defines |
| 1004 | +the requirements for a receiver type that is usable as |
| 1005 | +the first argument of a set of completion operations |
| 1006 | +corresponding to a set of completion signatures. |
| 1007 | +The \tcode{get_env} customization point object is used to access |
| 1008 | +a receiver's associated environment. |
| 1009 | +\begin{codeblock} |
| 1010 | +namespace std::execution { |
| 1011 | + template<class Rcvr> |
| 1012 | + concept @\deflibconcept{receiver}@ = |
| 1013 | + @\libconcept{derived_from}@<typename remove_cvref_t<Rcvr>::receiver_concept, receiver_t> && |
| 1014 | + requires(const remove_cvref_t<Rcvr>& rcvr) { |
| 1015 | + { get_env(rcvr) } -> queryable; |
| 1016 | + } && |
| 1017 | + @\libconcept{move_constructible}@<remove_cvref_t<Rcvr>> && // rvalues are movable, and |
| 1018 | + @\libconcept{constructible_from}@<remove_cvref_t<Rcvr>, Rcvr>; // lvalues are copyable |
| 1019 | + |
| 1020 | + template<class Signature, class Rcvr> |
| 1021 | + concept @\defexposconcept{valid-completion-for}@ = |
| 1022 | + requires (Signature* sig) { |
| 1023 | + []<class Tag, class... Args>(Tag(*)(Args...)) |
| 1024 | + requires @\libconcept{callable}@<Tag, remove_cvref_t<Rcvr>, Args...> |
| 1025 | + {}(sig); |
| 1026 | + }; |
| 1027 | + |
| 1028 | + template<class Rcvr, class Completions> |
| 1029 | + concept @\defexposconcept{has-completions}@ = |
| 1030 | + requires (Completions* completions) { |
| 1031 | + []<@\exposconcept{valid-completion-for}@<Rcvr>...Sigs>(completion_signatures<Sigs...>*) |
| 1032 | + {}(completions); |
| 1033 | + }; |
| 1034 | + |
| 1035 | + template<class Rcvr, class Completions> |
| 1036 | + concept @\deflibconcept{receiver_of}@ = |
| 1037 | + @\libconcept{receiver}@<Rcvr> && @\exposconcept{has-completions}@<Rcvr, Completions>; |
| 1038 | +} |
| 1039 | +\end{codeblock} |
| 1040 | + |
| 1041 | +\pnum |
| 1042 | +Class types that are marked \tcode{final} do not model the receiver concept. |
| 1043 | + |
| 1044 | +\pnum |
| 1045 | +Let \tcode{rcvr} be a receiver and |
| 1046 | +let \tcode{op_state} be an operation state associated with |
| 1047 | +an asynchronous operation created by connecting \tcode{rcvr} with a sender. |
| 1048 | +Let \tcode{token} be a stop token equal to |
| 1049 | +\tcode{get_stop_token(get_env(rcvr))}. |
| 1050 | +\tcode{token} shall remain valid |
| 1051 | +for the duration of the asynchronous operation's lifetime\iref{exec.async.ops}. |
| 1052 | +\begin{note} |
| 1053 | +This means that, unless it knows about further guarantees |
| 1054 | +provided by the type of \tcode{rcvr}, |
| 1055 | +the implementation of \tcode{op_state} cannot use \tcode{token} |
| 1056 | +after it executes a completion operation. |
| 1057 | +This also implies that any stop callbacks registered on token |
| 1058 | +must be destroyed before the invocation of the completion operation. |
| 1059 | +\end{note} |
| 1060 | + |
| 1061 | +\rSec2[exec.set.value]{\tcode{execution::set_value}} |
| 1062 | + |
| 1063 | +\pnum |
| 1064 | +\tcode{set_value} is a value completion function\iref{exec.async.ops}. |
| 1065 | +Its associated completion tag is \tcode{set_value_t}. |
| 1066 | +The expression \tcode{set_value(rcvr, vs...)} |
| 1067 | +for a subexpression \tcode{rcvr} and |
| 1068 | +pack of subexpressions \tcode{vs} is ill-formed |
| 1069 | +if \tcode{rcvr} is an lvalue or an rvalue of const type. |
| 1070 | +Otherwise, it is expression-equivalent to |
| 1071 | +\tcode{\exposid{MANDATE-NOTHROW}(rcvr.set_value(vs...))}. |
| 1072 | + |
| 1073 | +\rSec2[exec.set.error]{\tcode{execution::set_error}} |
| 1074 | + |
| 1075 | +\pnum |
| 1076 | +\tcode{set_error} is an error completion function\iref{exec.async.ops}. |
| 1077 | +Its associated completion tag is \tcode{set_error_t}. |
| 1078 | +The expression \tcode{set_error(rcvr, err)} |
| 1079 | +for some \tcode{subexpressions} \tcode{rcvr} and \tcode{err} is ill-formed |
| 1080 | +if \tcode{rcvr} is an lvalue or an rvalue of const type. |
| 1081 | +Otherwise, it is expression-equivalent to |
| 1082 | +\tcode{\exposid{MANDATE-NOTHROW}(rcvr.set_error(err))}. |
| 1083 | + |
| 1084 | +\rSec2[exec.set.stopped]{\tcode{execution::set_stopped}} |
| 1085 | + |
| 1086 | +\pnum |
| 1087 | +\tcode{set_stopped} is a stopped completion function\iref{exec.async.ops}. |
| 1088 | +Its associated completion tag is \tcode{set_stopped_t}. |
| 1089 | +The expression \tcode{set_stopped(rcvr)} |
| 1090 | +for a subexpression \tcode{rcvr} is ill-formed |
| 1091 | +if \tcode{rcvr} is an lvalue or an rvalue of const type. |
| 1092 | +Otherwise, it is expression-equivalent to |
| 1093 | +\tcode{\exposid{MANDATE-NOTHROW}(rcvr.set_stopped())}. |
1002 | 1094 |
|
1003 | 1095 | \rSec1[exec.opstate]{Operation states}
|
1004 | 1096 |
|
|
0 commit comments