tmp/tmpibmpsi9c/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Introduction <a id="thread.stoptoken.intro">[[thread.stoptoken.intro]]</a>
|
| 2 |
+
|
| 3 |
+
This clause describes components that can be used to asynchonously
|
| 4 |
+
request that an operation stops execution in a timely manner, typically
|
| 5 |
+
because the result is no longer required. Such a request is called a
|
| 6 |
+
*stop request*.
|
| 7 |
+
|
| 8 |
+
`stop_source`, `stop_token`, and `stop_callback` implement semantics of
|
| 9 |
+
shared ownership of a *stop state*. Any `stop_source`, `stop_token`, or
|
| 10 |
+
`stop_callback` that shares ownership of the same stop state is an
|
| 11 |
+
*associated* `stop_source`, `stop_token`, or `stop_callback`,
|
| 12 |
+
respectively. The last remaining owner of the stop state automatically
|
| 13 |
+
releases the resources associated with the stop state.
|
| 14 |
+
|
| 15 |
+
A `stop_token` can be passed to an operation which can either
|
| 16 |
+
|
| 17 |
+
- actively poll the token to check if there has been a stop request, or
|
| 18 |
+
- register a callback using the `stop_callback` class template which
|
| 19 |
+
will be called in the event that a stop request is made.
|
| 20 |
+
|
| 21 |
+
A stop request made via a `stop_source` will be visible to all
|
| 22 |
+
associated `stop_token` and `stop_source` objects. Once a stop request
|
| 23 |
+
has been made it cannot be withdrawn (a subsequent stop request has no
|
| 24 |
+
effect).
|
| 25 |
+
|
| 26 |
+
Callbacks registered via a `stop_callback` object are called when a stop
|
| 27 |
+
request is first made by any associated `stop_source` object.
|
| 28 |
+
|
| 29 |
+
Calls to the functions `request_stop`, `stop_requested`, and
|
| 30 |
+
`stop_possible` do not introduce data races. A call to `request_stop`
|
| 31 |
+
that returns `true` synchronizes with a call to `stop_requested` on an
|
| 32 |
+
associated `stop_token` or `stop_source` object that returns `true`.
|
| 33 |
+
Registration of a callback synchronizes with the invocation of that
|
| 34 |
+
callback.
|
| 35 |
+
|