Files
cppdraft_translate/cppdraft/exec/recv.md
2025-10-25 03:02:53 +03:00

6.4 KiB
Raw Blame History

[exec.recv]

33 Execution control library [exec]

33.7 Receivers [exec.recv]

33.7.1 Receiver concepts [exec.recv.concepts]

1

#

A receiver represents the continuation of an asynchronous operation.

The receiver concept defines the requirements for a receiver type ([exec.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.

namespace std::execution {templateconcept receiver =derived_from<typename remove_cvref_t::receiver_concept, receiver_t> &&requires(const remove_cvref_t& rcvr) {{ get_env(rcvr) } -> queryable; } &&move_constructible<remove_cvref_t> && // rvalues are movable, andconstructible_from<remove_cvref_t, Rcvr>; // lvalues are copyabletemplate<class Signature, class Rcvr>concept valid-completion-for = // exposition onlyrequires (Signature* sig) {[]<class Tag, class... Args>(Tag()(Args...))requires callable<Tag, remove_cvref_t, Args...>{}(sig); }; template<class Rcvr, class Completions>concept has-completions = // exposition onlyrequires (Completions completions) {[]<valid-completion-for...Sigs>(completion_signatures<Sigs...>*){}(completions); }; template<class Rcvr, class Completions>concept receiver_of =receiver && has-completions<Rcvr, Completions>;}

2

#

Class types that are marked final do not model the receiver concept.

3

#

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.

Let token be a stop token equal toget_stop_token(get_env(rcvr)).

token shall remain valid for the duration of the asynchronous operation's lifetime ([exec.async.ops]).

[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.

This also implies that any stop callbacks registered on token must be destroyed before the invocation of the completion operation.

— end note]

33.7.2 execution::set_value [exec.set.value]

1

#

set_value is a value completion function ([exec.async.ops]).

Its associated completion tag is set_value_t.

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.

Otherwise, it is expression-equivalent toMANDATE-NOTHROW(rcvr.set_value(vs...)).

33.7.3 execution::set_error [exec.set.error]

1

#

set_error is an error completion function ([exec.async.ops]).

Its associated completion tag is set_error_t.

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.

Otherwise, it is expression-equivalent toMANDATE-NOTHROW(rcvr.set_error(err)).

33.7.4 execution::set_stopped [exec.set.stopped]

1

#

set_stopped is a stopped completion function ([exec.async.ops]).

Its associated completion tag is set_stopped_t.

The expression set_stopped(rcvr) for a subexpression rcvr is ill-formed if rcvr is an lvalue or an rvalue of const type.

Otherwise, it is expression-equivalent toMANDATE-NOTHROW(rcvr.set_stopped()).