29 #ifndef _GLIBCXX_CONDITION_VARIABLE
30 #define _GLIBCXX_CONDITION_VARIABLE 1
32 #pragma GCC system_header
34 #if __cplusplus < 201103L
46 #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
48 namespace std _GLIBCXX_VISIBILITY(default)
50 _GLIBCXX_BEGIN_NAMESPACE_VERSION
66 typedef chrono::system_clock __clock_t;
67 typedef __gthread_cond_t __native_type;
69 #ifdef __GTHREAD_COND_INIT
70 __native_type _M_cond = __GTHREAD_COND_INIT;
72 __native_type _M_cond;
76 typedef __native_type* native_handle_type;
85 notify_one() noexcept;
88 notify_all() noexcept;
93 template<
typename _Predicate>
101 template<
typename _Duration>
105 {
return __wait_until_impl(__lock, __atime); }
107 template<
typename _Clock,
typename _Duration>
113 const typename _Clock::time_point __c_entry = _Clock::now();
114 const __clock_t::time_point __s_entry = __clock_t::now();
115 const auto __delta = __atime - __c_entry;
116 const auto __s_atime = __s_entry + __delta;
118 return __wait_until_impl(__lock, __s_atime);
121 template<
typename _Clock,
typename _Duration,
typename _Predicate>
128 if (wait_until(__lock, __atime) == cv_status::timeout)
133 template<
typename _Rep,
typename _Period>
137 {
return wait_until(__lock, __clock_t::now() + __rtime); }
139 template<
typename _Rep,
typename _Period,
typename _Predicate>
144 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
151 template<
typename _Dur>
159 __gthread_time_t __ts =
161 static_cast<std::time_t
>(__s.time_since_epoch().count()),
162 static_cast<long>(__ns.count())
165 __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
168 return (__clock_t::now() < __atime
169 ? cv_status::no_timeout : cv_status::timeout);
173 inline namespace _V2 {
179 typedef chrono::system_clock __clock_t;
184 template<
typename _Lock>
187 explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); }
189 ~_Unlock() noexcept(
false)
192 __try { _M_lock.lock(); } __catch(...) { }
197 _Unlock(
const _Unlock&) =
delete;
198 _Unlock& operator=(
const _Unlock&) =
delete;
211 notify_one() noexcept
214 _M_cond.notify_one();
218 notify_all() noexcept
221 _M_cond.notify_all();
224 template<
typename _Lock>
230 _Unlock<_Lock> __unlock(__lock);
234 _M_cond.wait(__my_lock2);
238 template<
typename _Lock,
typename _Predicate>
240 wait(_Lock& __lock, _Predicate __p)
246 template<
typename _Lock,
typename _Clock,
typename _Duration>
248 wait_until(_Lock& __lock,
253 _Unlock<_Lock> __unlock(__lock);
257 return _M_cond.wait_until(__my_lock2, __atime);
260 template<
typename _Lock,
typename _Clock,
261 typename _Duration,
typename _Predicate>
263 wait_until(_Lock& __lock,
268 if (wait_until(__lock, __atime) == cv_status::timeout)
273 template<
typename _Lock,
typename _Rep,
typename _Period>
276 {
return wait_until(__lock, __clock_t::now() + __rtime); }
278 template<
typename _Lock,
typename _Rep,
279 typename _Period,
typename _Predicate>
281 wait_for(_Lock& __lock,
283 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
289 _GLIBCXX_END_NAMESPACE_VERSION
292 #endif // _GLIBCXX_HAS_GTHREADS && _GLIBCXX_USE_C99_STDINT_TR1
296 #endif // _GLIBCXX_CONDITION_VARIABLE
bool uncaught_exception() 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
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