From Jason Turner

[stopcallback]

Diff to HTML by rtfpessoa

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