tmp/tmpg8cxnv5r/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Constructors, move, and assignment <a id="thread.jthread.cons">[[thread.jthread.cons]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
jthread() noexcept;
|
| 5 |
+
```
|
| 6 |
+
|
| 7 |
+
*Effects:* Constructs a `jthread` object that does not represent a
|
| 8 |
+
thread of execution.
|
| 9 |
+
|
| 10 |
+
*Ensures:* `get_id() == id()` is `true` and `ssource.stop_possible()` is
|
| 11 |
+
`false`.
|
| 12 |
+
|
| 13 |
+
``` cpp
|
| 14 |
+
template<class F, class... Args> explicit jthread(F&& f, Args&&... args);
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
*Constraints:* `remove_cvref_t<F>` is not the same type as `jthread`.
|
| 18 |
+
|
| 19 |
+
*Mandates:* The following are all `true`:
|
| 20 |
+
|
| 21 |
+
- `is_constructible_v<decay_t<F>, F>`,
|
| 22 |
+
- `(is_constructible_v<decay_t<Args>, Args> && ...)`,
|
| 23 |
+
- `is_move_constructible_v<decay_t<F>>`,
|
| 24 |
+
- `(is_move_constructible_v<decay_t<Args>> && ...)`, and
|
| 25 |
+
- `is_invocable_v<decay_t<F>, decay_t<Args>...> ||`
|
| 26 |
+
`is_invocable_v<decay_t<F>, stop_token, decay_t<Args>...>`.
|
| 27 |
+
|
| 28 |
+
*Preconditions:* `decay_t<F>` and each type in `decay_t<Args>` meet the
|
| 29 |
+
*Cpp17MoveConstructible* requirements.
|
| 30 |
+
|
| 31 |
+
*Effects:* Initializes `ssource`. The new thread of execution executes
|
| 32 |
+
|
| 33 |
+
``` cpp
|
| 34 |
+
invoke(decay-copy(std::forward<F>(f)), get_stop_token(),
|
| 35 |
+
decay-copy(std::forward<Args>(args))...)
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
if that expression is well-formed, otherwise
|
| 39 |
+
|
| 40 |
+
``` cpp
|
| 41 |
+
invoke(decay-copy(std::forward<F>(f)), decay-copy(std::forward<Args>(args))...)
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
with the calls to *`decay-copy`* being evaluated in the constructing
|
| 45 |
+
thread. Any return value from this invocation is ignored.
|
| 46 |
+
|
| 47 |
+
[*Note 1*: This implies that any exceptions not thrown from the
|
| 48 |
+
invocation of the copy of `f` will be thrown in the constructing thread,
|
| 49 |
+
not the new thread. — *end note*]
|
| 50 |
+
|
| 51 |
+
If the `invoke` expression exits via an exception, `terminate` is
|
| 52 |
+
called.
|
| 53 |
+
|
| 54 |
+
*Synchronization:* The completion of the invocation of the constructor
|
| 55 |
+
synchronizes with the beginning of the invocation of the copy of `f`.
|
| 56 |
+
|
| 57 |
+
*Ensures:* `get_id() != id()` is `true` and `ssource.stop_possible()` is
|
| 58 |
+
`true` and `*this` represents the newly started thread.
|
| 59 |
+
|
| 60 |
+
[*Note 2*: The calling thread can make a stop request only once,
|
| 61 |
+
because it cannot replace this stop token. — *end note*]
|
| 62 |
+
|
| 63 |
+
*Throws:* `system_error` if unable to start the new thread.
|
| 64 |
+
|
| 65 |
+
*Error conditions:*
|
| 66 |
+
|
| 67 |
+
- `resource_unavailable_try_again` — the system lacked the necessary
|
| 68 |
+
resources to create another thread, or the system-imposed limit on the
|
| 69 |
+
number of threads in a process would be exceeded.
|
| 70 |
+
|
| 71 |
+
``` cpp
|
| 72 |
+
jthread(jthread&& x) noexcept;
|
| 73 |
+
```
|
| 74 |
+
|
| 75 |
+
*Ensures:* `x.get_id() == id()` and `get_id()` returns the value of
|
| 76 |
+
`x.get_id()` prior to the start of construction. `ssource` has the value
|
| 77 |
+
of `x.ssource` prior to the start of construction and
|
| 78 |
+
`x.ssource.stop_possible()` is `false`.
|
| 79 |
+
|
| 80 |
+
``` cpp
|
| 81 |
+
~jthread();
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
*Effects:* If `joinable()` is `true`, calls `request_stop()` and then
|
| 85 |
+
`join()`.
|
| 86 |
+
|
| 87 |
+
[*Note 3*: Operations on `*this` are not synchronized. — *end note*]
|
| 88 |
+
|
| 89 |
+
``` cpp
|
| 90 |
+
jthread& operator=(jthread&& x) noexcept;
|
| 91 |
+
```
|
| 92 |
+
|
| 93 |
+
*Effects:* If `joinable()` is `true`, calls `request_stop()` and then
|
| 94 |
+
`join()`. Assigns the state of `x` to `*this` and sets `x` to a default
|
| 95 |
+
constructed state.
|
| 96 |
+
|
| 97 |
+
*Ensures:* `x.get_id() == id()` and `get_id()` returns the value of
|
| 98 |
+
`x.get_id()` prior to the assignment. `ssource` has the value of
|
| 99 |
+
`x.ssource` prior to the assignment and `x.ssource.stop_possible()` is
|
| 100 |
+
`false`.
|
| 101 |
+
|
| 102 |
+
*Returns:* `*this`.
|
| 103 |
+
|