From Jason Turner

[stoptoken]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphenhu5wz/{from.md → to.md} +27 -90
tmp/tmphenhu5wz/{from.md → to.md} RENAMED
@@ -1,129 +1,66 @@
1
  ### Class `stop_token` <a id="stoptoken">[[stoptoken]]</a>
2
 
3
  #### General <a id="stoptoken.general">[[stoptoken.general]]</a>
4
 
5
- The class `stop_token` provides an interface for querying whether a stop
6
- request has been made (`stop_requested`) or can ever be made
7
- (`stop_possible`) using an associated `stop_source` object
8
- [[stopsource]]. A `stop_token` can also be passed to a `stop_callback`
9
- [[stopcallback]] constructor to register a callback to be called when a
10
- stop request has been made from an associated `stop_source`.
11
 
12
  ``` cpp
13
  namespace std {
14
  class stop_token {
15
  public:
16
- // [stoptoken.cons], constructors, copy, and assignment
17
- stop_token() noexcept;
18
 
19
- stop_token(const stop_token&) noexcept;
20
- stop_token(stop_token&&) noexcept;
21
- stop_token& operator=(const stop_token&) noexcept;
22
- stop_token& operator=(stop_token&&) noexcept;
23
- ~stop_token();
24
  void swap(stop_token&) noexcept;
25
 
26
- // [stoptoken.mem], stop handling
27
- [[nodiscard]] bool stop_requested() const noexcept;
28
- [[nodiscard]] bool stop_possible() const noexcept;
29
 
30
- [[nodiscard]] friend bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
31
- friend void swap(stop_token& lhs, stop_token& rhs) noexcept;
 
 
32
  };
33
  }
34
  ```
35
 
36
- #### Constructors, copy, and assignment <a id="stoptoken.cons">[[stoptoken.cons]]</a>
 
37
 
38
- ``` cpp
39
- stop_token() noexcept;
40
- ```
41
-
42
- *Ensures:* `stop_possible()` is `false` and `stop_requested()` is
43
- `false`.
44
-
45
- [*Note 1*: Because the created `stop_token` object can never receive a
46
- stop request, no resources are allocated for a stop
47
- state. — *end note*]
48
-
49
- ``` cpp
50
- stop_token(const stop_token& rhs) noexcept;
51
- ```
52
-
53
- *Ensures:* `*this == rhs` is `true`.
54
-
55
- [*Note 2*: `*this` and `rhs` share the ownership of the same stop
56
- state, if any. — *end note*]
57
-
58
- ``` cpp
59
- stop_token(stop_token&& rhs) noexcept;
60
- ```
61
-
62
- *Ensures:* `*this` contains the value of `rhs` prior to the start of
63
- construction and `rhs.stop_possible()` is `false`.
64
-
65
- ``` cpp
66
- ~stop_token();
67
- ```
68
-
69
- *Effects:* Releases ownership of the stop state, if any.
70
-
71
- ``` cpp
72
- stop_token& operator=(const stop_token& rhs) noexcept;
73
- ```
74
-
75
- *Effects:* Equivalent to: `stop_token(rhs).swap(*this)`.
76
-
77
- *Returns:* `*this`.
78
-
79
- ``` cpp
80
- stop_token& operator=(stop_token&& rhs) noexcept;
81
- ```
82
-
83
- *Effects:* Equivalent to: `stop_token(std::move(rhs)).swap(*this)`.
84
-
85
- *Returns:* `*this`.
86
 
87
  ``` cpp
88
  void swap(stop_token& rhs) noexcept;
89
  ```
90
 
91
- *Effects:* Exchanges the values of `*this` and `rhs`.
92
 
93
- #### Members <a id="stoptoken.mem">[[stoptoken.mem]]</a>
 
 
94
 
95
  ``` cpp
96
- [[nodiscard]] bool stop_requested() const noexcept;
97
  ```
98
 
99
- *Returns:* `true` if `*this` has ownership of a stop state that has
100
  received a stop request; otherwise, `false`.
101
 
102
  ``` cpp
103
- [[nodiscard]] bool stop_possible() const noexcept;
104
  ```
105
 
106
- *Returns:* `false` if:
107
 
108
- - `*this` does not have ownership of a stop state, or
109
  - a stop request was not made and there are no associated `stop_source`
110
  objects;
111
 
112
  otherwise, `true`.
113
 
114
- #### Non-member functions <a id="stoptoken.nonmembers">[[stoptoken.nonmembers]]</a>
115
-
116
- ``` cpp
117
- [[nodiscard]] bool operator==(const stop_token& lhs, const stop_token& rhs) noexcept;
118
- ```
119
-
120
- *Returns:* `true` if `lhs` and `rhs` have ownership of the same stop
121
- state or if both `lhs` and `rhs` do not have ownership of a stop state;
122
- otherwise `false`.
123
-
124
- ``` cpp
125
- friend void swap(stop_token& x, stop_token& y) noexcept;
126
- ```
127
-
128
- *Effects:* Equivalent to: `x.swap(y)`.
129
-
 
1
  ### Class `stop_token` <a id="stoptoken">[[stoptoken]]</a>
2
 
3
  #### General <a id="stoptoken.general">[[stoptoken.general]]</a>
4
 
5
+ The class `stop_token` models the concept `stoppable_token`. It shares
6
+ ownership of its stop state, if any, with its associated `stop_source`
7
+ object [[stopsource]] and any `stop_token` objects to which it compares
8
+ equal.
 
 
9
 
10
  ``` cpp
11
  namespace std {
12
  class stop_token {
13
  public:
14
+ template<class CallbackFn>
15
+ using callback_type = stop_callback<CallbackFn>;
16
 
17
+ stop_token() noexcept = default;
18
+
19
+ // [stoptoken.mem], member functions
 
 
20
  void swap(stop_token&) noexcept;
21
 
22
+ bool stop_requested() const noexcept;
23
+ bool stop_possible() const noexcept;
 
24
 
25
+ bool operator==(const stop_token& rhs) noexcept = default;
26
+
27
+ private:
28
+ shared_ptr<unspecified> stop-state; // exposition only
29
  };
30
  }
31
  ```
32
 
33
+ *`stop-state`* refers to the `stop_token`’s associated stop state. A
34
+ `stop_token` object is disengaged when *`stop-state`* is empty.
35
 
36
+ #### Member functions <a id="stoptoken.mem">[[stoptoken.mem]]</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  ``` cpp
39
  void swap(stop_token& rhs) noexcept;
40
  ```
41
 
42
+ *Effects:* Equivalent to:
43
 
44
+ ``` cpp
45
+ stop-state.swap(rhs.stop-state);
46
+ ```
47
 
48
  ``` cpp
49
+ bool stop_requested() const noexcept;
50
  ```
51
 
52
+ *Returns:* `true` if *stop-state* refers to a stop state that has
53
  received a stop request; otherwise, `false`.
54
 
55
  ``` cpp
56
+ bool stop_possible() const noexcept;
57
  ```
58
 
59
+ *Returns:* `false` if
60
 
61
+ - `*this` is disengaged, or
62
  - a stop request was not made and there are no associated `stop_source`
63
  objects;
64
 
65
  otherwise, `true`.
66