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;
63 __native_type _M_cond;
66 typedef __native_type* native_handle_type;
83 template<
typename _Predicate>
91 template<
typename _Duration>
95 {
return __wait_until_impl(__lock, __atime); }
97 template<
typename _Clock,
typename _Duration>
103 const typename _Clock::time_point __c_entry = _Clock::now();
108 return __wait_until_impl(__lock, __s_atime);
111 template<
typename _Clock,
typename _Duration,
typename _Predicate>
118 if (wait_until(__lock, __atime) == cv_status::timeout)
123 template<
typename _Rep,
typename _Period>
127 {
return wait_until(__lock, __clock_t::now() + __rtime); }
129 template<
typename _Rep,
typename _Period,
typename _Predicate>
134 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
141 template<
typename _Clock,
typename _Duration>
152 __gthread_time_t __ts =
154 static_cast<std::time_t
>(__s.time_since_epoch().count()),
155 static_cast<long>(__ns.count())
158 __gthread_cond_timedwait(&_M_cond, __lock.mutex()->native_handle(),
161 return (_Clock::now() < __atime
162 ? cv_status::no_timeout : cv_status::timeout);
175 template<
typename _Lock>
178 explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); }
180 ~_Unlock() noexcept(
false)
183 __try { _M_lock.lock(); } __catch(...) { }
188 _Unlock(
const _Unlock&) =
delete;
189 _Unlock& operator=(
const _Unlock&) =
delete;
195 typedef condition_variable::native_handle_type native_handle_type;
207 _M_cond.notify_one();
214 _M_cond.notify_all();
217 template<
typename _Lock>
222 _Unlock<_Lock> __unlock(__lock);
226 _M_cond.wait(__my_lock2);
230 template<
typename _Lock,
typename _Predicate>
232 wait(_Lock& __lock, _Predicate __p)
238 template<
typename _Lock,
typename _Clock,
typename _Duration>
240 wait_until(_Lock& __lock,
244 _Unlock<_Lock> __unlock(__lock);
248 return _M_cond.wait_until(__my_lock2, __atime);
251 template<
typename _Lock,
typename _Clock,
252 typename _Duration,
typename _Predicate>
254 wait_until(_Lock& __lock,
259 if (wait_until(__lock, __atime) == cv_status::timeout)
264 template<
typename _Lock,
typename _Rep,
typename _Period>
267 {
return wait_until(__lock, __clock_t::now() + __rtime); }
269 template<
typename _Lock,
typename _Rep,
270 typename _Period,
typename _Predicate>
272 wait_for(_Lock& __lock,
274 {
return wait_until(__lock, __clock_t::now() + __rtime, std::move(__p)); }
278 {
return _M_cond.native_handle(); }
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