29 #ifndef _GLIBCXX_CONDITION_VARIABLE
30 #define _GLIBCXX_CONDITION_VARIABLE 1
32 #pragma GCC system_header
34 #ifndef __GXX_EXPERIMENTAL_CXX0X__
41 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
43 namespace std _GLIBCXX_VISIBILITY(default)
45 _GLIBCXX_BEGIN_NAMESPACE_VERSION
62 typedef __gthread_cond_t __native_type;
64 #ifdef __GTHREAD_COND_INIT
65 __native_type _M_cond = __GTHREAD_COND_INIT;
67 __native_type _M_cond;
71 typedef __native_type* native_handle_type;
80 notify_one() noexcept;
83 notify_all() noexcept;
88 template<
typename _Predicate>
96 template<
typename _Duration>
100 {
return __wait_until_impl(__lock, __atime); }
102 template<
typename _Clock,
typename _Duration>
108 const typename _Clock::time_point __c_entry = _Clock::now();
110 const auto __delta = __atime - __c_entry;
111 const auto __s_atime = __s_entry + __delta;
113 return __wait_until_impl(__lock, __s_atime);
116 template<
typename _Clock,
typename _Duration,
typename _Predicate>
123 if (wait_until(__lock, __atime) == cv_status::timeout)
128 template<
typename _Rep,
typename _Period>
132 {
return wait_until(__lock, __clock_t::now() + __rtime); }
134 template<
typename _Rep,
typename _Period,
typename _Predicate>
139 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
146 template<
typename _Clock,
typename _Duration>
157 __gthread_time_t __ts =
159 static_cast<std::time_t
>(__s.time_since_epoch().count()),
160 static_cast<long>(__ns.count())
163 __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
166 return (_Clock::now() < __atime
167 ? cv_status::no_timeout : cv_status::timeout);
180 template<
typename _Lock>
183 explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); }
185 ~_Unlock() noexcept(
false)
188 __try { _M_lock.lock(); } __catch(...) { }
193 _Unlock(
const _Unlock&) =
delete;
194 _Unlock& operator=(
const _Unlock&) =
delete;
208 notify_one() noexcept
211 _M_cond.notify_one();
215 notify_all() noexcept
218 _M_cond.notify_all();
221 template<
typename _Lock>
226 _Unlock<_Lock> __unlock(__lock);
230 _M_cond.wait(__my_lock2);
234 template<
typename _Lock,
typename _Predicate>
236 wait(_Lock& __lock, _Predicate __p)
242 template<
typename _Lock,
typename _Clock,
typename _Duration>
244 wait_until(_Lock& __lock,
248 _Unlock<_Lock> __unlock(__lock);
252 return _M_cond.wait_until(__my_lock2, __atime);
255 template<
typename _Lock,
typename _Clock,
256 typename _Duration,
typename _Predicate>
258 wait_until(_Lock& __lock,
263 if (wait_until(__lock, __atime) == cv_status::timeout)
268 template<
typename _Lock,
typename _Rep,
typename _Period>
271 {
return wait_until(__lock, __clock_t::now() + __rtime); }
273 template<
typename _Lock,
typename _Rep,
274 typename _Period,
typename _Predicate>
276 wait_for(_Lock& __lock,
278 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
282 _GLIBCXX_END_NAMESPACE_VERSION
285 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
287 #endif // __GXX_EXPERIMENTAL_CXX0X__
289 #endif // _GLIBCXX_CONDITION_VARIABLE
bool uncaught_exception() _GLIBCXX_USE_NOEXCEPT __attribute__((__pure__))
constexpr enable_if< __is_duration< _ToDur >::value, time_point< _Clock, _ToDur > >::type time_point_cast(const time_point< _Clock, _Dur > &__t)
time_point_cast
constexpr enable_if< __is_duration< _ToDur >::value, _ToDur >::type duration_cast(const duration< _Rep, _Period > &__d)
duration_cast