Skip to content

Commit 7ce40de

Browse files
authored
Merge pull request #39 from dietmarkuehl/HEAD
Head
2 parents 61e316c + 1c12327 commit 7ce40de

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

docs/overview.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,21 @@ Required members for <code>_Token_</code>:
252252
- <code>std::copyable&lt;_Token_&gt;</code>
253253
- <code>std::equality_comparable&lt;_Token_&gt;</code>
254254
- <code>std::swapable&lt;_Token_&gt;</code>
255-
<blockquote>
255+
<div>
256+
<details>
257+
<summary>Example: concept use</summary>
258+
<div>
259+
260+
```c++
261+
static_assert(std::execution::unstoppable_token<std::execution::never_stop_token>);
262+
static_assert(std::execution::unstoppable_token<std::execution::stop_token>);
263+
static_assert(std::execution::unstoppable_token<std::execution::inline_stop_token>);
264+
```
265+
</div>
266+
</details>
256267
<details>
257268
<summary>Example: polling</summary>
269+
<div>
258270
This example shows a sketch of using a <code>stoppable_token&lt;_Token_&gt;</code> to cancel an active operation. The computation in this example is represented as `sleep_for`.
259271
260272
```c++
@@ -266,9 +278,11 @@ void compute(std::stoppable_token auto token)
266278
}
267279
}
268280
```
281+
</div>
269282
</details>
270283
<details>
271284
<summary>Example: inactive</summary>
285+
<div>
272286
This example shows how an <code><a href=‘#operation-state’>operation_state</a></code> can use the <code>callback_type</code> together with a <code>_token_</code> to get notified when cancellation is requested.
273287

274288
```c++
@@ -305,7 +319,7 @@ struct example_state
305319
}
306320
auto stop() {
307321
unregister_work(this);
308-
if (--this->outstanding == 0u)
322+
if (this->outstanding == 0u)
309323
std::execution::set_stopped(std::move(this->receiver));
310324
}
311325
auto complete() {
@@ -316,11 +330,25 @@ struct example_state
316330
}
317331
};
318332
```
333+
</div>
319334
</details>
320-
</blockquote>
335+
</div>
321336
</details>
322337
<details>
323-
<summary><code>unstoppable_token&lt;Token&gt;</code> TODO</summary>
338+
<summary><code>unstoppable_token&lt;_Token_&gt;</code></summary>
339+
The concept <code>unstoppable_token&lt;Token&gt;</code> is modeled by a <code>_Token_</code> if <code>stoppable_token&lt;_Token_&gt;</code> is true and it can statically be determined that both <code>_token_.stop_requested()</code> and <code>_token_.stop_possible()</code> are `constexpr` epxressions yielding `false`. This concept is primarily used to avoid extra work when using stop tokens which will never indicate that cancellations are requested.
340+
<div>
341+
<details>
342+
<summary>Example</summary>
343+
The concept yields `true` for the <code><a href=‘#never-stop-token’>std::execution::never_stop_token</a></code>:
344+
345+
```c++
346+
static_assert(std::execution::unstoppable_token<std::execution::never_stop_token>);
347+
static_assert(not std::execution::unstoppable_token<std::execution::stop_token>);
348+
static_assert(not std::execution::unstoppable_token<std::execution::inline_stop_token>);
349+
```
350+
</details>
351+
</div>
324352
</details>
325353

326354
## Queries

examples/stopping.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct inject_cancel_sender
7070

7171
template <typename Receiver>
7272
auto connect(Receiver&& recv) && {
73-
return ex::connect(std::move(sender), receiver<Receiver>(std::forward<Receiver>(recv), this->token));
73+
return ex::connect(std::move(sender), receiver<Receiver>{std::forward<Receiver>(recv), this->token});
7474
}
7575
};
7676

0 commit comments

Comments
 (0)