65#ifdef _GLIBCXX_HAS_GTHREADS
71 virtual void _M_run() = 0;
75 using native_handle_type = __gthread_t;
77 using native_handle_type = int;
83 native_handle_type _M_thread;
86 id() noexcept : _M_thread() { }
89 id(native_handle_type __id) : _M_thread(__id) { }
93 friend struct hash<id>;
96 operator==(
id __x,
id __y)
noexcept;
98#if __cpp_lib_three_way_comparison
99 friend strong_ordering
100 operator<=>(
id __x,
id __y)
noexcept;
103 operator<(
id __x,
id __y)
noexcept;
106 template<
class _CharT,
class _Traits>
117 template<
typename _Tp>
118 using __not_same = __not_<is_same<__remove_cvref_t<_Tp>, thread>>;
121 thread() noexcept = default;
123#ifdef _GLIBCXX_HAS_GTHREADS
124 template<
typename _Callable,
typename... _Args,
125 typename = _Require<__not_same<_Callable>>>
127 thread(_Callable&& __f, _Args&&... __args)
129 static_assert( __is_invocable<typename decay<_Callable>::type,
130 typename decay<_Args>::type...>::value,
131 "std::thread arguments must be invocable after conversion to rvalues"
134#ifdef GTHR_ACTIVE_PROXY
136 auto __depend =
reinterpret_cast<void(*)()
>(&pthread_create);
138 auto __depend =
nullptr;
140 using _Wrapper = _Call_wrapper<_Callable, _Args...>;
143 _M_start_thread(_State_ptr(
new _State_impl<_Wrapper>(
155 thread(
const thread&) =
delete;
157 thread(thread&& __t)
noexcept
160 thread& operator=(
const thread&) =
delete;
162 thread& operator=(thread&& __t)
noexcept
171 swap(thread& __t)
noexcept
175 joinable() const noexcept
176 {
return !(_M_id ==
id()); }
185 get_id() const noexcept
192 {
return _M_id._M_thread; }
196 hardware_concurrency() noexcept;
198#ifdef _GLIBCXX_HAS_GTHREADS
200 template<
typename _Callable>
201 struct _State_impl :
public _State
205 template<
typename... _Args>
206 _State_impl(_Args&&... __args)
211 _M_run() { _M_func(); }
215 _M_start_thread(_State_ptr,
void (*)());
217#if _GLIBCXX_THREAD_ABI_COMPAT
220 typedef shared_ptr<_Impl_base> __shared_base_type;
223 __shared_base_type _M_this_ptr;
224 virtual ~_Impl_base() =
default;
225 virtual void _M_run() = 0;
230 _M_start_thread(__shared_base_type,
void (*)());
233 _M_start_thread(__shared_base_type);
238 template<
typename _Tuple>
241 template<
typename... _Args>
243 _Invoker(_Args&&... __args)
244 : _M_t(std::
forward<_Args>(__args)...)
251 template<
typename _Fn,
typename... _Args>
252 struct __result<tuple<_Fn, _Args...>>
253 : __invoke_result<_Fn, _Args...>
256 template<
size_t... _Ind>
257 typename __result<_Tuple>::type
258 _M_invoke(_Index_tuple<_Ind...>)
261 typename __result<_Tuple>::type
265 =
typename _Build_index_tuple<tuple_size<_Tuple>::value>::__type;
266 return _M_invoke(_Indices());
271 template<
typename... _Tp>
272 using _Call_wrapper = _Invoker<tuple<typename decay<_Tp>::type...>>;
constexpr __invoke_result< _Callable, _Args... >::type __invoke(_Callable &&__fn, _Args &&... __args) noexcept(__is_nothrow_invocable< _Callable, _Args... >::value)
Invoke a callable object.