tmp/tmpppzcmske/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
### Class `jthread` <a id="thread.jthread.class">[[thread.jthread.class]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
The class `jthread` provides a mechanism to create a new thread of
|
| 4 |
execution. The functionality is the same as for class `thread`
|
| 5 |
[[thread.thread.class]] with the additional abilities to provide a
|
| 6 |
`stop_token` [[thread.stoptoken]] to the new thread of execution, make
|
| 7 |
stop requests, and automatically join.
|
|
@@ -67,34 +69,30 @@ template<class F, class... Args> explicit jthread(F&& f, Args&&... args);
|
|
| 67 |
*Constraints:* `remove_cvref_t<F>` is not the same type as `jthread`.
|
| 68 |
|
| 69 |
*Mandates:* The following are all `true`:
|
| 70 |
|
| 71 |
- `is_constructible_v<decay_t<F>, F>`,
|
| 72 |
-
- `(is_constructible_v<decay_t<Args>, Args> && ...)`,
|
| 73 |
-
- `is_move_constructible_v<decay_t<F>>`,
|
| 74 |
-
- `(is_move_constructible_v<decay_t<Args>> && ...)`, and
|
| 75 |
- `is_invocable_v<decay_t<F>, decay_t<Args>...> ||`
|
| 76 |
`is_invocable_v<decay_t<F>, stop_token, decay_t<Args>...>`.
|
| 77 |
|
| 78 |
-
*Preconditions:* `decay_t<F>` and each type in `decay_t<Args>` meet the
|
| 79 |
-
*Cpp17MoveConstructible* requirements.
|
| 80 |
-
|
| 81 |
*Effects:* Initializes `ssource`. The new thread of execution executes
|
| 82 |
|
| 83 |
``` cpp
|
| 84 |
-
invoke(
|
| 85 |
-
|
| 86 |
```
|
| 87 |
|
| 88 |
if that expression is well-formed, otherwise
|
| 89 |
|
| 90 |
``` cpp
|
| 91 |
-
invoke(
|
| 92 |
```
|
| 93 |
|
| 94 |
-
with the
|
| 95 |
-
thread. Any return value from this invocation is
|
|
|
|
| 96 |
|
| 97 |
[*Note 1*: This implies that any exceptions not thrown from the
|
| 98 |
invocation of the copy of `f` will be thrown in the constructing thread,
|
| 99 |
not the new thread. — *end note*]
|
| 100 |
|
|
@@ -138,18 +136,18 @@ of `x.ssource` prior to the start of construction and
|
|
| 138 |
|
| 139 |
``` cpp
|
| 140 |
jthread& operator=(jthread&& x) noexcept;
|
| 141 |
```
|
| 142 |
|
| 143 |
-
*Effects:* If `
|
| 144 |
-
`
|
|
|
|
| 145 |
constructed state.
|
| 146 |
|
| 147 |
-
*Ensures:* `
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
`false`.
|
| 151 |
|
| 152 |
*Returns:* `*this`.
|
| 153 |
|
| 154 |
#### Members <a id="thread.jthread.mem">[[thread.jthread.mem]]</a>
|
| 155 |
|
|
|
|
| 1 |
### Class `jthread` <a id="thread.jthread.class">[[thread.jthread.class]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="thread.jthread.class.general">[[thread.jthread.class.general]]</a>
|
| 4 |
+
|
| 5 |
The class `jthread` provides a mechanism to create a new thread of
|
| 6 |
execution. The functionality is the same as for class `thread`
|
| 7 |
[[thread.thread.class]] with the additional abilities to provide a
|
| 8 |
`stop_token` [[thread.stoptoken]] to the new thread of execution, make
|
| 9 |
stop requests, and automatically join.
|
|
|
|
| 69 |
*Constraints:* `remove_cvref_t<F>` is not the same type as `jthread`.
|
| 70 |
|
| 71 |
*Mandates:* The following are all `true`:
|
| 72 |
|
| 73 |
- `is_constructible_v<decay_t<F>, F>`,
|
| 74 |
+
- `(is_constructible_v<decay_t<Args>, Args> && ...)`, and
|
|
|
|
|
|
|
| 75 |
- `is_invocable_v<decay_t<F>, decay_t<Args>...> ||`
|
| 76 |
`is_invocable_v<decay_t<F>, stop_token, decay_t<Args>...>`.
|
| 77 |
|
|
|
|
|
|
|
|
|
|
| 78 |
*Effects:* Initializes `ssource`. The new thread of execution executes
|
| 79 |
|
| 80 |
``` cpp
|
| 81 |
+
invoke(auto(std::forward<F>(f)), get_stop_token(), // for invoke, see [func.invoke]
|
| 82 |
+
auto(std::forward<Args>(args))...)
|
| 83 |
```
|
| 84 |
|
| 85 |
if that expression is well-formed, otherwise
|
| 86 |
|
| 87 |
``` cpp
|
| 88 |
+
invoke(auto(std::forward<F>(f)), auto(std::forward<Args>(args))...)
|
| 89 |
```
|
| 90 |
|
| 91 |
+
with the values produced by `auto` being materialized [[conv.rval]] in
|
| 92 |
+
the constructing thread. Any return value from this invocation is
|
| 93 |
+
ignored.
|
| 94 |
|
| 95 |
[*Note 1*: This implies that any exceptions not thrown from the
|
| 96 |
invocation of the copy of `f` will be thrown in the constructing thread,
|
| 97 |
not the new thread. — *end note*]
|
| 98 |
|
|
|
|
| 136 |
|
| 137 |
``` cpp
|
| 138 |
jthread& operator=(jthread&& x) noexcept;
|
| 139 |
```
|
| 140 |
|
| 141 |
+
*Effects:* If `&x == this` is `true`, there are no effects. Otherwise,
|
| 142 |
+
if `joinable()` is `true`, calls `request_stop()` and then `join()`,
|
| 143 |
+
then assigns the state of `x` to `*this` and sets `x` to a default
|
| 144 |
constructed state.
|
| 145 |
|
| 146 |
+
*Ensures:* `get_id()` returns the value of `x.get_id()` prior to the
|
| 147 |
+
assignment. `ssource` has the value of `x.ssource` prior to the
|
| 148 |
+
assignment.
|
|
|
|
| 149 |
|
| 150 |
*Returns:* `*this`.
|
| 151 |
|
| 152 |
#### Members <a id="thread.jthread.mem">[[thread.jthread.mem]]</a>
|
| 153 |
|