[thread.jthread.class.general] (original) (raw)
The class jthread provides a mechanism to create a new thread of execution.
The functionality is the same as for class thread ([thread.thread.class]) with the additional abilities to provide a stop_token ([thread.stoptoken]) to the new thread of execution, make stop requests, and automatically join.
namespace std { class jthread { public: using id = thread::id;using native_handle_type = thread::native_handle_type; jthread() noexcept;template<class F, class... Args> explicit jthread(F&& f, Args&&... args);~jthread(); jthread(const jthread&) = delete; jthread(jthread&&) noexcept; jthread& operator=(const jthread&) = delete; jthread& operator=(jthread&&) noexcept;void swap(jthread&) noexcept;bool joinable() const noexcept;void join();void detach(); id get_id() const noexcept; native_handle_type native_handle(); stop_source get_stop_source() noexcept; stop_token get_stop_token() const noexcept;bool request_stop() noexcept;friend void swap(jthread& lhs, jthread& rhs) noexcept;static unsigned int hardware_concurrency() noexcept;private: stop_source ssource; };}