29 #ifndef _GLIBCXX_CONDITION_VARIABLE
30 #define _GLIBCXX_CONDITION_VARIABLE 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
44 #include <bits/shared_ptr.h>
47 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
49 namespace std _GLIBCXX_VISIBILITY(default)
51 _GLIBCXX_BEGIN_NAMESPACE_VERSION
67 typedef chrono::system_clock __clock_t;
68 typedef __gthread_cond_t __native_type;
70 #ifdef __GTHREAD_COND_INIT
71 __native_type _M_cond = __GTHREAD_COND_INIT;
73 __native_type _M_cond;
77 typedef __native_type* native_handle_type;
86 notify_one() noexcept;
89 notify_all() noexcept;
94 template<
typename _Predicate>
102 template<
typename _Duration>
106 {
return __wait_until_impl(__lock, __atime); }
108 template<
typename _Clock,
typename _Duration>
114 const typename _Clock::time_point __c_entry = _Clock::now();
115 const __clock_t::time_point __s_entry = __clock_t::now();
116 const auto __delta = __atime - __c_entry;
117 const auto __s_atime = __s_entry + __delta;
119 return __wait_until_impl(__lock, __s_atime);
122 template<
typename _Clock,
typename _Duration,
typename _Predicate>
129 if (wait_until(__lock, __atime) == cv_status::timeout)
134 template<
typename _Rep,
typename _Period>
138 {
return wait_until(__lock, __clock_t::now() + __rtime); }
140 template<
typename _Rep,
typename _Period,
typename _Predicate>
145 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
152 template<
typename _Dur>
160 __gthread_time_t __ts =
162 static_cast<std::time_t
>(__s.time_since_epoch().count()),
163 static_cast<long>(__ns.count())
166 __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
169 return (__clock_t::now() < __atime
170 ? cv_status::no_timeout : cv_status::timeout);
177 struct __at_thread_exit_elt
179 __at_thread_exit_elt* _M_next;
180 void (*_M_cb)(
void*);
183 inline namespace _V2 {
189 typedef chrono::system_clock __clock_t;
194 template<
typename _Lock>
197 explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); }
199 ~_Unlock() noexcept(
false)
206 { __throw_exception_again; }
214 _Unlock(
const _Unlock&) =
delete;
215 _Unlock& operator=(
const _Unlock&) =
delete;
228 notify_one() noexcept
231 _M_cond.notify_one();
235 notify_all() noexcept
238 _M_cond.notify_all();
241 template<
typename _Lock>
247 _Unlock<_Lock> __unlock(__lock);
251 _M_cond.wait(__my_lock2);
255 template<
typename _Lock,
typename _Predicate>
257 wait(_Lock& __lock, _Predicate __p)
263 template<
typename _Lock,
typename _Clock,
typename _Duration>
265 wait_until(_Lock& __lock,
270 _Unlock<_Lock> __unlock(__lock);
274 return _M_cond.wait_until(__my_lock2, __atime);
277 template<
typename _Lock,
typename _Clock,
278 typename _Duration,
typename _Predicate>
280 wait_until(_Lock& __lock,
285 if (wait_until(__lock, __atime) == cv_status::timeout)
290 template<
typename _Lock,
typename _Rep,
typename _Period>
293 {
return wait_until(__lock, __clock_t::now() + __rtime); }
295 template<
typename _Lock,
typename _Rep,
296 typename _Period,
typename _Predicate>
298 wait_for(_Lock& __lock,
300 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
306 _GLIBCXX_END_NAMESPACE_VERSION
309 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
313 #endif // _GLIBCXX_CONDITION_VARIABLE
A movable scoped lock type.
A simple scoped lock type.
A smart pointer with reference-counted copy semantics.
constexpr enable_if< __is_duration< _ToDur >::value, _ToDur >::type duration_cast(const duration< _Rep, _Period > &__d)
duration_cast
constexpr enable_if< __is_duration< _ToDur >::value, time_point< _Clock, _ToDur > >::type time_point_cast(const time_point< _Clock, _Dur > &__t)
time_point_cast
bool uncaught_exception() noexcept __attribute__((__pure__))
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...