37 this->_inner_thread = std::move(other._inner_thread);
38 this->
id = this->_inner_thread.get_id();
49 template <
class F,
class... Args>
explicit jthread(F &&f, Args &&...args)
51 this->_inner_thread = std::thread(f, args...);
52 this->
id = this->_inner_thread.get_id();
59 this->_inner_thread.join();
65 return this->_inner_thread.joinable();
68 std::thread::id
get_id() const noexcept
70 return this->_inner_thread.get_id();
80 return this->_inner_thread.native_handle();
92 return std::thread::hardware_concurrency();
97 this->_inner_thread.join();
102 this->_inner_thread.detach();
107 this->_inner_thread.swap(other._inner_thread);
108 this->
id = this->_inner_thread.get_id();
109 other.id = other._inner_thread.get_id();
112#if __cplusplus >= 202002L
113 std::stop_source get_stop_source() noexcept
115 return this->_stop_source;
118 std::stop_token get_stop_token() const noexcept
120 return this->_stop_source.get_token();
123 bool request_stop() noexcept
125 return this->_stop_source.request_stop();
130 std::thread _inner_thread;
131#if __cplusplus >= 202002L
132 std::stop_source _stop_source;
The jthread class is a wrapper around std::thread that automatically rejoins the thread on destructio...
jthread(F &&f, Args &&...args)
Construct a new jthread object with the given function and arguments.
bool joinable() const noexcept
jthread() noexcept=default
static unsigned int hardware_concurrency() noexcept
Get the number of concurrent threads supported by the implementation.
native_handle_type native_handle()
Get the native handle of the thread.
void swap(tenno::jthread &other) noexcept
std::thread::native_handle_type native_handle_type
The type of the implementation defined thread handle.
std::thread::id get_id() const noexcept