tmp/tmpgkchj301/{from.md → to.md}
RENAMED
|
@@ -2,86 +2,74 @@
|
|
| 2 |
|
| 3 |
#### General <a id="stopcallback.general">[[stopcallback.general]]</a>
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
namespace std {
|
| 7 |
-
template<class
|
| 8 |
class stop_callback {
|
| 9 |
public:
|
| 10 |
-
using callback_type =
|
| 11 |
|
| 12 |
// [stopcallback.cons], constructors and destructor
|
| 13 |
-
template<class
|
| 14 |
-
explicit stop_callback(const stop_token& st,
|
| 15 |
-
noexcept(is_nothrow_constructible_v<
|
| 16 |
-
template<class
|
| 17 |
-
explicit stop_callback(stop_token&& st,
|
| 18 |
-
noexcept(is_nothrow_constructible_v<
|
| 19 |
~stop_callback();
|
| 20 |
|
| 21 |
stop_callback(const stop_callback&) = delete;
|
| 22 |
stop_callback(stop_callback&&) = delete;
|
| 23 |
stop_callback& operator=(const stop_callback&) = delete;
|
| 24 |
stop_callback& operator=(stop_callback&&) = delete;
|
| 25 |
|
| 26 |
private:
|
| 27 |
-
|
| 28 |
};
|
| 29 |
|
| 30 |
-
template<class
|
| 31 |
-
stop_callback(stop_token,
|
| 32 |
}
|
| 33 |
```
|
| 34 |
|
| 35 |
*Mandates:* `stop_callback` is instantiated with an argument for the
|
| 36 |
-
template parameter `
|
| 37 |
`destructible`.
|
| 38 |
|
| 39 |
-
*
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
#### Constructors and destructor <a id="stopcallback.cons">[[stopcallback.cons]]</a>
|
| 44 |
|
| 45 |
``` cpp
|
| 46 |
-
template<class
|
| 47 |
-
explicit stop_callback(const stop_token& st,
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 52 |
```
|
| 53 |
|
| 54 |
-
*Constraints:* `
|
| 55 |
-
`constructible_from<
|
| 56 |
-
|
| 57 |
-
*
|
| 58 |
-
`
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
`std::forward<Callback>(callback)()` is evaluated in the current thread
|
| 63 |
-
before the constructor returns. Otherwise, if `st` has ownership of a
|
| 64 |
-
stop state, acquires shared ownership of that stop state and registers
|
| 65 |
-
the callback with that stop state such that
|
| 66 |
-
`std::forward<Callback>(callback)()` is evaluated by the first call to
|
| 67 |
-
`request_stop()` on an associated `stop_source`.
|
| 68 |
-
|
| 69 |
-
*Throws:* Any exception thrown by the initialization of `callback`.
|
| 70 |
-
|
| 71 |
-
*Remarks:* If evaluating `std::forward<Callback>(callback)()` exits via
|
| 72 |
-
an exception, then `terminate` is invoked [[except.terminate]].
|
| 73 |
|
| 74 |
``` cpp
|
| 75 |
~stop_callback();
|
| 76 |
```
|
| 77 |
|
| 78 |
-
*Effects:*
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
concurrently executing on another thread, then the return from the
|
| 82 |
-
invocation of `callback` strongly happens before [[intro.races]]
|
| 83 |
-
`callback` is destroyed. If `callback` is executing on the current
|
| 84 |
-
thread, then the destructor does not block [[defns.block]] waiting for
|
| 85 |
-
the return from the invocation of `callback`. Releases ownership of the
|
| 86 |
-
stop state, if any.
|
| 87 |
|
|
|
|
| 2 |
|
| 3 |
#### General <a id="stopcallback.general">[[stopcallback.general]]</a>
|
| 4 |
|
| 5 |
``` cpp
|
| 6 |
namespace std {
|
| 7 |
+
template<class CallbackFn>
|
| 8 |
class stop_callback {
|
| 9 |
public:
|
| 10 |
+
using callback_type = CallbackFn;
|
| 11 |
|
| 12 |
// [stopcallback.cons], constructors and destructor
|
| 13 |
+
template<class Initializer>
|
| 14 |
+
explicit stop_callback(const stop_token& st, Initializer&& init)
|
| 15 |
+
noexcept(is_nothrow_constructible_v<CallbackFn, Initializer>);
|
| 16 |
+
template<class Initializer>
|
| 17 |
+
explicit stop_callback(stop_token&& st, Initializer&& init)
|
| 18 |
+
noexcept(is_nothrow_constructible_v<CallbackFn, Initializer>);
|
| 19 |
~stop_callback();
|
| 20 |
|
| 21 |
stop_callback(const stop_callback&) = delete;
|
| 22 |
stop_callback(stop_callback&&) = delete;
|
| 23 |
stop_callback& operator=(const stop_callback&) = delete;
|
| 24 |
stop_callback& operator=(stop_callback&&) = delete;
|
| 25 |
|
| 26 |
private:
|
| 27 |
+
CallbackFn callback-fn; // exposition only
|
| 28 |
};
|
| 29 |
|
| 30 |
+
template<class CallbackFn>
|
| 31 |
+
stop_callback(stop_token, CallbackFn) -> stop_callback<CallbackFn>;
|
| 32 |
}
|
| 33 |
```
|
| 34 |
|
| 35 |
*Mandates:* `stop_callback` is instantiated with an argument for the
|
| 36 |
+
template parameter `CallbackFn` that satisfies both `invocable` and
|
| 37 |
`destructible`.
|
| 38 |
|
| 39 |
+
*Remarks:* For a type `Initializer`, if
|
| 40 |
+
`stoppable-callback-for<CallbackFn, stop_token, Initializer>` is
|
| 41 |
+
satisfied, then
|
| 42 |
+
`stoppable-callback-for<CallbackFn, stop_token, Initializer>` is
|
| 43 |
+
modeled. The exposition-only *`callback-fn`* member is the associated
|
| 44 |
+
callback function [[stoptoken.concepts]] of `stop_callback< CallbackFn>`
|
| 45 |
+
objects.
|
| 46 |
|
| 47 |
#### Constructors and destructor <a id="stopcallback.cons">[[stopcallback.cons]]</a>
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
+
template<class Initializer>
|
| 51 |
+
explicit stop_callback(const stop_token& st, Initializer&& init)
|
| 52 |
+
noexcept(is_nothrow_constructible_v<CallbackFn, Initializer>);
|
| 53 |
+
|
| 54 |
+
template<class Initializer>
|
| 55 |
+
explicit stop_callback(stop_token&& st, Initializer&& init)
|
| 56 |
+
noexcept(is_nothrow_constructible_v<CallbackFn, Initializer>);
|
| 57 |
```
|
| 58 |
|
| 59 |
+
*Constraints:* `CallbackFn` and `Initializer` satisfy
|
| 60 |
+
`constructible_from<CallbackFn, Initializer>`.
|
| 61 |
+
|
| 62 |
+
*Effects:* Initializes *callback-fn* with
|
| 63 |
+
`std::forward<Initializer>(init)` and executes a stoppable callback
|
| 64 |
+
registration [[stoptoken.concepts]]. If a callback is registered with
|
| 65 |
+
`st`’s shared stop state, then `*this` acquires shared ownership of that
|
| 66 |
+
stop state.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
``` cpp
|
| 69 |
~stop_callback();
|
| 70 |
```
|
| 71 |
|
| 72 |
+
*Effects:* Executes a stoppable callback
|
| 73 |
+
deregistration [[stoptoken.concepts]] and releases ownership of the stop
|
| 74 |
+
state, if any.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|