3.6 KiB
[exec.stop.when]
33 Execution control library [exec]
33.9 Senders [exec.snd]
33.9.12 Sender adaptors [exec.adapt]
33.9.12.17 Exposition-only execution::stop-when [exec.stop.when]
stop-when fuses an additional stop token t into a sender so that, upon connecting to a receiver r, the resulting operation state receives stop requests from botht and the token returned from get_stop_token(get_env(r)).
The name stop-when denotes an exposition-only sender adaptor.
For subexpressions sndr and token:
-
If decltype((sndr)) does not satisfy sender, orremove_cvref_t<decltype((token))> does not satisfy stoppable_token, then stop-when(sndr, token) is ill-formed.
-
Otherwise, if remove_cvref_t<decltype((token))> modelsunstoppable_token thenstop-when(sndr, token) is expression-equivalent tosndr.
-
Otherwise,stop-when(sndr, token) returns a sender osndr. If osndr is connected to a receiver r, let rtoken be the result of get_stop_token(get_env(r)).
-
If the type of rtoken models unstoppable_token then the effects of connecting osndr to r are equivalent toconnect(write_env(sndr, prop(get_stop_token, token)), r).
-
Otherwise, the effects of connecting osndr to r are equivalent toconnect(write_env(sndr, prop(get_stop_token, stoken)), r) where stoken is an object of an exposition-only type stoken-t such that: + (2.3.2.1) stoken-t models stoppable_token;
-
[(2.3.2.2)](#2.3.2.2)
-
-
stoken.stop_requested() returns token.stop_requested() || rtoken.stop_reques-
ted();
+
[(2.3.2.3)](#2.3.2.3)
stoken.stop_possible() returns token.stop_possible() || rtoken.stop_possible(); and
+
[(2.3.2.4)](#2.3.2.4)
for types Fn and Init such that both invocable and constructible_from<Fn, Init> are modeled, stoken-t::callback_type models stoppable-callback-for<Fn, stoken-t, Init>. [Note 1: For an object fn of type Fn constructed from a value, init, of type Init, registering fn using stoken-t::callback_type(stoken, init) results in an invocation of fn when a callback registered with token or rtoken would be invoked. fn is invoked at most once. â end note]