Provided by: libstdc++-13-doc_13-20230320-1ubuntu1_all
NAME
std::jthread
SYNOPSIS
#include <thread> Public Types using id = thread::id using native_handle_type = thread::native_handle_type Public Member Functions template<typename _Callable , typename... _Args, typename = enable_if_t<!is_same_v<remove_cvref_t<_Callable>, jthread>>> jthread (_Callable &&__f, _Args &&... __args) jthread (const jthread &)=delete jthread (jthread &&) noexcept=default void detach () id get_id () const noexcept stop_source get_stop_source () noexcept stop_token get_stop_token () const noexcept void join () bool joinable () const noexcept native_handle_type native_handle () jthread & operator= (const jthread &)=delete jthread & operator= (jthread &&__other) noexcept bool request_stop () noexcept void swap (jthread &__other) noexcept Static Public Member Functions static unsigned hardware_concurrency () noexcept Friends void swap (jthread &__lhs, jthread &__rhs) noexcept
Detailed Description
A thread with cancellation and automatic joining. Unlike std::thread, destroying a joinable std::jthread will not terminate the process. Instead, it will try to request its thread to stop, then will join it. A std::jthread has a std::stop_source member which will be passed as the first argument to the callable that runs in the new thread (as long as the callable will accept that argument). That can then be used to send a stop request that the new thread can test for. Since C++20 Definition at line 134 of file thread.
Member Typedef Documentation
using std::jthread::id = thread::id Definition at line 137 of file thread. using std::jthread::native_handle_type = thread::native_handle_type Definition at line 138 of file thread.
Constructor & Destructor Documentation
std::jthread::jthread () [inline], [noexcept] Definition at line 140 of file thread. template<typename _Callable , typename... _Args, typename = enable_if_t<!is_same_v<remove_cvref_t<_Callable>, jthread>>> std::jthread::jthread (_Callable && __f, _Args &&... __args) [inline], [explicit] Definition at line 148 of file thread. std::jthread::~jthread () [inline] Definition at line 156 of file thread.
Member Function Documentation
void std::jthread::detach () [inline] Definition at line 195 of file thread. id std::jthread::get_id () const [inline], [noexcept] Definition at line 201 of file thread. stop_source std::jthread::get_stop_source () [inline], [noexcept] Definition at line 219 of file thread. stop_token std::jthread::get_stop_token () const [inline], [noexcept] Definition at line 225 of file thread. static unsigned std::jthread::hardware_concurrency () [inline], [static], [noexcept] Definition at line 213 of file thread. void std::jthread::join () [inline] Definition at line 189 of file thread. bool std::jthread::joinable () const [inline], [noexcept] Definition at line 183 of file thread. native_handle_type std::jthread::native_handle () [inline] Definition at line 207 of file thread. jthread & std::jthread::operator= (jthread && __other) [inline], [noexcept] Definition at line 169 of file thread. bool std::jthread::request_stop () [inline], [noexcept] Definition at line 230 of file thread. void std::jthread::swap (jthread & __other) [inline], [noexcept] Definition at line 176 of file thread.
Friends And Related Function Documentation
void swap (jthread & __lhs, jthread & __rhs) [friend] Definition at line 235 of file thread.
Author
Generated automatically by Doxygen for libstdc++ from the source code.