+ [[nodiscard]] stop_source
+ get_stop_source() noexcept
+ {
+ return _M_stop_source;
+ }
+
+ [[nodiscard]] stop_token
+ get_stop_token() const noexcept
+ {
+ return _M_stop_source.get_token();
+ }
+
+ bool request_stop() noexcept
+ {
+ return _M_stop_source.request_stop();
+ }
+
+ friend void swap(jthread& __lhs, jthread& __rhs) noexcept
+ {
+ __lhs.swap(__rhs);
+ }
+
+ private:
+ template<typename _Callable, typename... _Args>
+ static thread
+ _S_create(stop_source& __ssrc, _Callable&& __f, _Args&&... __args)
+ {
+ if constexpr(is_invocable_v<decay_t<_Callable>, stop_token,
+ decay_t<_Args>...>)
+ return thread{std::forward<_Callable>(__f), __ssrc.get_token(),
+ std::forward<_Args>(__args)...};
+ else
+ {
+ static_assert(is_invocable_v<decay_t<_Callable>,
+ decay_t<_Args>...>,
+ "std::thread arguments must be invocable after"
+ " conversion to rvalues");
+ return thread{std::forward<_Callable>(__f),
+ std::forward<_Args>(__args)...};
+ }
+ }
+
+ stop_source _M_stop_source;
+ thread _M_thread;
+ };
+#endif // __cpp_lib_jthread