74 lines
3.6 KiB
Markdown
74 lines
3.6 KiB
Markdown
[exec.stop.when]
|
||
|
||
# 33 Execution control library [[exec]](./#exec)
|
||
|
||
## 33.9 Senders [[exec.snd]](exec.snd#exec.stop.when)
|
||
|
||
### 33.9.12 Sender adaptors [[exec.adapt]](exec.adapt#exec.stop.when)
|
||
|
||
#### 33.9.12.17 Exposition-only execution::*stop-when* [exec.stop.when]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L5154)
|
||
|
||
*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))[.](#1.sentence-1)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/exec.tex#L5161)
|
||
|
||
The name *stop-when* denotes an exposition-only sender adaptor[.](#2.sentence-1)
|
||
|
||
For subexpressions sndr and token:
|
||
|
||
- [(2.1)](#2.1)
|
||
|
||
If decltype((sndr)) does not satisfy [sender](exec.snd.concepts#concept:sender "33.9.3 Sender concepts [exec.snd.concepts]"), orremove_cvref_t<decltype((token))> does not satisfy [stoppable_token](stoptoken.concepts#concept:stoppable_token "32.3.3 Stop token concepts [stoptoken.concepts]"),
|
||
then *stop-when*(sndr, token) is ill-formed[.](#2.1.sentence-1)
|
||
|
||
- [(2.2)](#2.2)
|
||
|
||
Otherwise,
|
||
if remove_cvref_t<decltype((token))> models[unstoppable_token](stoptoken.concepts#concept:unstoppable_token "32.3.3 Stop token concepts [stoptoken.concepts]") then*stop-when*(sndr, token) is expression-equivalent tosndr[.](#2.2.sentence-1)
|
||
|
||
- [(2.3)](#2.3)
|
||
|
||
Otherwise,*stop-when*(sndr, token) returns a sender osndr[.](#2.3.sentence-1)
|
||
If osndr is connected to a receiver r,
|
||
let rtoken be the result of get_stop_token(get_env(r))[.](#2.3.sentence-2)
|
||
|
||
* [(2.3.1)](#2.3.1)
|
||
|
||
If the type of rtoken models [unstoppable_token](stoptoken.concepts#concept:unstoppable_token "32.3.3 Stop token concepts [stoptoken.concepts]") then
|
||
the effects of connecting osndr to r are equivalent toconnect(write_env(sndr, prop(get_stop_token, token)), r)[.](#2.3.1.sentence-1)
|
||
|
||
* [(2.3.2)](#2.3.2)
|
||
|
||
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)](#2.3.2.1)
|
||
*stoken-t* models [stoppable_token](stoptoken.concepts#concept:stoppable_token "32.3.3 Stop token concepts [stoptoken.concepts]");
|
||
|
||
+
|
||
[(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](concept.invocable#concept:invocable "18.7.2 Concept invocable [concept.invocable]")<Fn> and [constructible_from](concept.constructible#concept:constructible_from "18.4.11 Concept constructible_from [concept.constructible]")<Fn, Init> are modeled, *stoken-t*::callback_type<Fn> models [*stoppable-callback-for*](stoptoken.concepts#concept:stoppable-callback-for "32.3.3 Stop token concepts [stoptoken.concepts]")<Fn, *stoken-t*, Init>[.](#2.3.2.sentence-1)
|
||
[*Note [1](#note-1)*:
|
||
For an object fn of type Fn constructed from a value, init, of type Init,
|
||
registering fn using *stoken-t*::callback_type<Fn>(stoken, init) results in an invocation of fn when
|
||
a callback registered with token or rtoken would be invoked[.](#2.3.2.4.sentence-2)
|
||
fn is invoked at most once[.](#2.3.2.4.sentence-3)
|
||
â *end note*]
|