29 #ifndef _GLIBCXX_THREAD
30 #define _GLIBCXX_THREAD 1
32 #pragma GCC system_header
34 #ifndef __GXX_EXPERIMENTAL_CXX0X__
45 #include <bits/gthr.h>
47 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
49 namespace std _GLIBCXX_VISIBILITY(default)
51 _GLIBCXX_BEGIN_NAMESPACE_VERSION
65 typedef __gthread_t native_handle_type;
72 native_handle_type _M_thread;
75 id() : _M_thread() { }
78 id(native_handle_type __id) : _M_thread(__id) { }
82 friend class hash<thread::
id>;
85 operator==(thread::id __x, thread::id __y)
86 {
return __gthread_equal(__x._M_thread, __y._M_thread); }
90 {
return __x._M_thread < __y._M_thread; }
92 template<
class _CharT,
class _Traits>
94 operator<<(basic_ostream<_CharT, _Traits>& __out,
thread::id __id);
103 inline virtual ~_Impl_base();
105 virtual void _M_run() = 0;
108 template<
typename _Callable>
109 struct _Impl :
public _Impl_base
113 _Impl(_Callable&& __f) : _M_func(std::
forward<_Callable>(__f))
117 _M_run() { _M_func(); }
125 thread(thread&) =
delete;
126 thread(
const thread&) =
delete;
131 template<
typename _Callable,
typename... _Args>
133 thread(_Callable&& __f, _Args&&... __args)
135 _M_start_thread(_M_make_routine(std::bind<void>(
136 std::forward<_Callable>(__f),
137 std::forward<_Args>(__args)...)));
146 thread& operator=(
const thread&) =
delete;
148 thread& operator=(thread&& __t)
158 { std::swap(_M_id, __t._M_id); }
162 {
return !(_M_id == id()); }
178 {
return _M_id._M_thread; }
182 hardware_concurrency()
187 _M_start_thread(__shared_base_type);
189 template<
typename _Callable>
190 shared_ptr<_Impl<_Callable>>
191 _M_make_routine(_Callable&& __f)
194 return make_shared<_Impl<_Callable>>(std::forward<_Callable>(__f));
198 inline thread::_Impl_base::~_Impl_base() =
default;
201 swap(thread& __x, thread& __y)
205 operator!=(thread::id __x, thread::id __y)
206 {
return !(__x == __y); }
209 operator<=(thread::id __x, thread::id __y)
210 {
return !(__y < __x); }
213 operator>(thread::id __x, thread::id __y)
214 {
return __y < __x; }
217 operator>=(thread::id __x, thread::id __y)
218 {
return !(__x < __y); }
224 :
public __hash_base<size_t, thread::id>
228 {
return std::_Hash_impl::hash(__id._M_thread); }
231 template<
class _CharT,
class _Traits>
233 operator<<(basic_ostream<_CharT, _Traits>& __out,
thread::id __id)
236 return __out <<
"thread::id of a non-executing thread";
238 return __out << __id._M_thread;
241 _GLIBCXX_END_NAMESPACE_VERSION
247 namespace this_thread
249 _GLIBCXX_BEGIN_NAMESPACE_VERSION
255 #ifdef _GLIBCXX_USE_SCHED_YIELD
259 { __gthread_yield(); }
262 #ifdef _GLIBCXX_USE_NANOSLEEP
264 template<
typename _Clock,
typename _Duration>
270 template<
typename _Rep,
typename _Period>
280 __gthread_time_t __ts =
282 static_cast<std::time_t
>(__s.count()),
283 static_cast<long>(__ns.count())
286 ::nanosleep(&__ts, 0);
290 _GLIBCXX_END_NAMESPACE_VERSION
297 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
299 #endif // __GXX_EXPERIMENTAL_CXX0X__
301 #endif // _GLIBCXX_THREAD
Controlling output.This is the base class for all output streams. It provides text formatting of all ...
void sleep_until(const chrono::time_point< _Clock, _Duration > &__atime)
sleep_until
constexpr enable_if< __is_duration< _ToDur >::value, _ToDur >::type duration_cast(const duration< _Rep, _Period > &__d)
duration_cast
void sleep_for(const chrono::duration< _Rep, _Period > &__rtime)
sleep_for
void terminate() __attribute__((__noreturn__))
thread::id get_id()
get_id
Primary class template hash.
native_handle_type native_handle()
_Tp && forward(typename std::remove_reference< _Tp >::type &__t)
forward (as per N3143)