29 #ifndef _GLIBCXX_CONDITION_VARIABLE
30 #define _GLIBCXX_CONDITION_VARIABLE 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
45 #include <bits/shared_ptr.h>
48 #if defined(_GLIBCXX_HAS_GTHREADS)
50 namespace std _GLIBCXX_VISIBILITY(default)
52 _GLIBCXX_BEGIN_NAMESPACE_VERSION
68 typedef chrono::system_clock __clock_t;
69 typedef chrono::steady_clock __steady_clock_t;
70 typedef __gthread_cond_t __native_type;
72 #ifdef __GTHREAD_COND_INIT
73 __native_type _M_cond = __GTHREAD_COND_INIT;
75 __native_type _M_cond;
79 typedef __native_type* native_handle_type;
96 template<
typename _Predicate>
104 template<
typename _Duration>
108 {
return __wait_until_impl(__lock, __atime); }
110 template<
typename _Clock,
typename _Duration>
116 const typename _Clock::time_point __c_entry = _Clock::now();
117 const __clock_t::time_point __s_entry = __clock_t::now();
118 const auto __delta = __atime - __c_entry;
119 const auto __s_atime = __s_entry + __delta;
121 if (__wait_until_impl(__lock, __s_atime) == cv_status::no_timeout)
122 return cv_status::no_timeout;
126 if (_Clock::now() < __atime)
127 return cv_status::no_timeout;
128 return cv_status::timeout;
131 template<
typename _Clock,
typename _Duration,
typename _Predicate>
138 if (wait_until(__lock, __atime) == cv_status::timeout)
143 template<
typename _Rep,
typename _Period>
148 using __dur =
typename __steady_clock_t::duration;
150 if (__reltime < __rtime)
152 return wait_until(__lock, __steady_clock_t::now() + __reltime);
155 template<
typename _Rep,
typename _Period,
typename _Predicate>
161 using __dur =
typename __steady_clock_t::duration;
163 if (__reltime < __rtime)
165 return wait_until(__lock, __steady_clock_t::now() + __reltime,
174 template<
typename _Dur>
182 __gthread_time_t __ts =
184 static_cast<std::time_t
>(__s.time_since_epoch().count()),
185 static_cast<long>(__ns.count())
188 __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
191 return (__clock_t::now() < __atime
192 ? cv_status::no_timeout : cv_status::timeout);
199 struct __at_thread_exit_elt
201 __at_thread_exit_elt* _M_next;
202 void (*_M_cb)(
void*);
205 inline namespace _V2 {
211 typedef chrono::system_clock __clock_t;
216 template<
typename _Lock>
219 explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); }
228 { __throw_exception_again; }
236 _Unlock(
const _Unlock&) =
delete;
237 _Unlock& operator=(
const _Unlock&) =
delete;
253 _M_cond.notify_one();
260 _M_cond.notify_all();
263 template<
typename _Lock>
269 _Unlock<_Lock> __unlock(__lock);
273 _M_cond.wait(__my_lock2);
277 template<
typename _Lock,
typename _Predicate>
279 wait(_Lock& __lock, _Predicate __p)
285 template<
typename _Lock,
typename _Clock,
typename _Duration>
287 wait_until(_Lock& __lock,
292 _Unlock<_Lock> __unlock(__lock);
296 return _M_cond.wait_until(__my_lock2, __atime);
299 template<
typename _Lock,
typename _Clock,
300 typename _Duration,
typename _Predicate>
302 wait_until(_Lock& __lock,
307 if (wait_until(__lock, __atime) == cv_status::timeout)
312 template<
typename _Lock,
typename _Rep,
typename _Period>
315 {
return wait_until(__lock, __clock_t::now() + __rtime); }
317 template<
typename _Lock,
typename _Rep,
318 typename _Period,
typename _Predicate>
320 wait_for(_Lock& __lock,
322 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
328 _GLIBCXX_END_NAMESPACE_VERSION
331 #endif // _GLIBCXX_HAS_GTHREADS
333 #endif // _GLIBCXX_CONDITION_VARIABLE
constexpr enable_if< __is_duration< _ToDur >::value, time_point< _Clock, _ToDur > >::type time_point_cast(const time_point< _Clock, _Dur > &__t)
time_point_cast
_GLIBCXX17_DEPRECATED bool uncaught_exception() noexcept __attribute__((__pure__))
A simple scoped lock type.
enable_if< ::__array_traits< _Tp, _Nm >::_Is_swappable::value >::type noexcept(noexcept(__one.swap(__two)))
swap
A movable scoped lock type.
A smart pointer with reference-counted copy semantics.
Thrown as part of forced unwinding.A magic placeholder class that can be caught by reference to recog...
constexpr __enable_if_is_duration< _ToDur > duration_cast(const duration< _Rep, _Period > &__d)
duration_cast