From Jason Turner

[stopcallback]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgkchj301/{from.md → to.md} +37 -49
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 Callback>
8
  class stop_callback {
9
  public:
10
- using callback_type = Callback;
11
 
12
  // [stopcallback.cons], constructors and destructor
13
- template<class C>
14
- explicit stop_callback(const stop_token& st, C&& cb)
15
- noexcept(is_nothrow_constructible_v<Callback, C>);
16
- template<class C>
17
- explicit stop_callback(stop_token&& st, C&& cb)
18
- noexcept(is_nothrow_constructible_v<Callback, C>);
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
- Callback callback; // exposition only
28
  };
29
 
30
- template<class Callback>
31
- stop_callback(stop_token, Callback) -> stop_callback<Callback>;
32
  }
33
  ```
34
 
35
  *Mandates:* `stop_callback` is instantiated with an argument for the
36
- template parameter `Callback` that satisfies both `invocable` and
37
  `destructible`.
38
 
39
- *Preconditions:* `stop_callback` is instantiated with an argument for
40
- the template parameter `Callback` that models both `invocable` and
41
- `destructible`.
 
 
 
 
42
 
43
  #### Constructors and destructor <a id="stopcallback.cons">[[stopcallback.cons]]</a>
44
 
45
  ``` cpp
46
- template<class C>
47
- explicit stop_callback(const stop_token& st, C&& cb)
48
- noexcept(is_nothrow_constructible_v<Callback, C>);
49
- template<class C>
50
- explicit stop_callback(stop_token&& st, C&& cb)
51
- noexcept(is_nothrow_constructible_v<Callback, C>);
 
52
  ```
53
 
54
- *Constraints:* `Callback` and `C` satisfy
55
- `constructible_from<Callback, C>`.
56
-
57
- *Preconditions:* `Callback` and `C` model
58
- `constructible_from<Callback, C>`.
59
-
60
- *Effects:* Initializes `callback` with `std::forward<C>(cb)`. If
61
- `st.stop_requested()` is `true`, then
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:* Unregisters the callback from the owned stop state, if any.
79
- The destructor does not block waiting for the execution of another
80
- callback registered by an associated `stop_callback`. If `callback` is
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