tmp/tmpvqv9qnv3/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### General <a id="thread.jthread.class.general">[[thread.jthread.class.general]]</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.
|
| 8 |
+
|
| 9 |
+
``` cpp
|
| 10 |
+
namespace std {
|
| 11 |
+
class jthread {
|
| 12 |
+
public:
|
| 13 |
+
// types
|
| 14 |
+
using id = thread::id;
|
| 15 |
+
using native_handle_type = thread::native_handle_type;
|
| 16 |
+
|
| 17 |
+
// [thread.jthread.cons], constructors, move, and assignment
|
| 18 |
+
jthread() noexcept;
|
| 19 |
+
template<class F, class... Args> explicit jthread(F&& f, Args&&... args);
|
| 20 |
+
~jthread();
|
| 21 |
+
jthread(const jthread&) = delete;
|
| 22 |
+
jthread(jthread&&) noexcept;
|
| 23 |
+
jthread& operator=(const jthread&) = delete;
|
| 24 |
+
jthread& operator=(jthread&&) noexcept;
|
| 25 |
+
|
| 26 |
+
// [thread.jthread.mem], members
|
| 27 |
+
void swap(jthread&) noexcept;
|
| 28 |
+
[[nodiscard]] bool joinable() const noexcept;
|
| 29 |
+
void join();
|
| 30 |
+
void detach();
|
| 31 |
+
[[nodiscard]] id get_id() const noexcept;
|
| 32 |
+
[[nodiscard]] native_handle_type native_handle(); // see~[thread.req.native]
|
| 33 |
+
|
| 34 |
+
// [thread.jthread.stop], stop token handling
|
| 35 |
+
[[nodiscard]] stop_source get_stop_source() noexcept;
|
| 36 |
+
[[nodiscard]] stop_token get_stop_token() const noexcept;
|
| 37 |
+
bool request_stop() noexcept;
|
| 38 |
+
|
| 39 |
+
// [thread.jthread.special], specialized algorithms
|
| 40 |
+
friend void swap(jthread& lhs, jthread& rhs) noexcept;
|
| 41 |
+
|
| 42 |
+
// [thread.jthread.static], static members
|
| 43 |
+
[[nodiscard]] static unsigned int hardware_concurrency() noexcept;
|
| 44 |
+
|
| 45 |
+
private:
|
| 46 |
+
stop_source ssource; // exposition only
|
| 47 |
+
};
|
| 48 |
+
}
|
| 49 |
+
```
|
| 50 |
+
|