tmp/tmpgssnher8/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Constructors and destructor <a id="stopcallback.cons">[[stopcallback.cons]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
template<class C>
|
| 5 |
+
explicit stop_callback(const stop_token& st, C&& cb)
|
| 6 |
+
noexcept(is_nothrow_constructible_v<Callback, C>);
|
| 7 |
+
template<class C>
|
| 8 |
+
explicit stop_callback(stop_token&& st, C&& cb)
|
| 9 |
+
noexcept(is_nothrow_constructible_v<Callback, C>);
|
| 10 |
+
```
|
| 11 |
+
|
| 12 |
+
*Constraints:* `Callback` and `C` satisfy
|
| 13 |
+
`constructible_from<Callback, C>`.
|
| 14 |
+
|
| 15 |
+
*Preconditions:* `Callback` and `C` model
|
| 16 |
+
`constructible_from<Callback, C>`.
|
| 17 |
+
|
| 18 |
+
*Effects:* Initializes `callback` with `std::forward<C>(cb)`. If
|
| 19 |
+
`st.stop_requested()` is `true`, then
|
| 20 |
+
`std::forward<Callback>(callback)()` is evaluated in the current thread
|
| 21 |
+
before the constructor returns. Otherwise, if `st` has ownership of a
|
| 22 |
+
stop state, acquires shared ownership of that stop state and registers
|
| 23 |
+
the callback with that stop state such that
|
| 24 |
+
`std::forward<Callback>(callback)()` is evaluated by the first call to
|
| 25 |
+
`request_stop()` on an associated `stop_source`.
|
| 26 |
+
|
| 27 |
+
*Remarks:* If evaluating `std::forward<Callback>(callback)()` exits via
|
| 28 |
+
an exception, then `terminate` is called [[except.terminate]].
|
| 29 |
+
|
| 30 |
+
*Throws:* Any exception thrown by the initialization of `callback`.
|
| 31 |
+
|
| 32 |
+
``` cpp
|
| 33 |
+
~stop_callback();
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
*Effects:* Unregisters the callback from the owned stop state, if any.
|
| 37 |
+
The destructor does not block waiting for the execution of another
|
| 38 |
+
callback registered by an associated `stop_callback`. If `callback` is
|
| 39 |
+
concurrently executing on another thread, then the return from the
|
| 40 |
+
invocation of `callback` strongly happens before [[intro.races]]
|
| 41 |
+
`callback` is destroyed. If `callback` is executing on the current
|
| 42 |
+
thread, then the destructor does not block [[defns.block]] waiting for
|
| 43 |
+
the return from the invocation of `callback`. Releases ownership of the
|
| 44 |
+
stop state, if any.
|
| 45 |
+
|