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`
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 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 |
-
|
| 17 |
-
|
| 18 |
|
| 19 |
-
stop_token(
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
stop_token& operator=(stop_token&&) noexcept;
|
| 23 |
-
~stop_token();
|
| 24 |
void swap(stop_token&) noexcept;
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
[[nodiscard]] bool stop_possible() const noexcept;
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
};
|
| 33 |
}
|
| 34 |
```
|
| 35 |
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
-
|
| 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:*
|
| 92 |
|
| 93 |
-
|
|
|
|
|
|
|
| 94 |
|
| 95 |
``` cpp
|
| 96 |
-
|
| 97 |
```
|
| 98 |
|
| 99 |
-
*Returns:* `true` if
|
| 100 |
received a stop request; otherwise, `false`.
|
| 101 |
|
| 102 |
``` cpp
|
| 103 |
-
|
| 104 |
```
|
| 105 |
|
| 106 |
-
*Returns:* `false` if
|
| 107 |
|
| 108 |
-
- `*this`
|
| 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|