76#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
85 typedef __gthread_cond_t* native_handle_type;
94 notify_one()
noexcept;
97 notify_all()
noexcept;
102 template<
typename _Predicate>
110#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
111 template<
typename _Duration>
115 {
return __wait_until_impl(__lock, __atime); }
118 template<
typename _Duration>
122 {
return __wait_until_impl(__lock, __atime); }
124 template<
typename _Clock,
typename _Duration>
129#if __cplusplus > 201703L
130 static_assert(chrono::is_clock_v<_Clock>);
132 using __s_dur =
typename __clock_t::duration;
133 const typename _Clock::time_point __c_entry = _Clock::now();
135 const auto __delta = __atime - __c_entry;
136 const auto __s_atime = __s_entry +
137 chrono::__detail::ceil<__s_dur>(__delta);
139 if (__wait_until_impl(__lock, __s_atime) == cv_status::no_timeout)
140 return cv_status::no_timeout;
144 if (_Clock::now() < __atime)
145 return cv_status::no_timeout;
146 return cv_status::timeout;
149 template<
typename _Clock,
typename _Duration,
typename _Predicate>
156 if (wait_until(__lock, __atime) == cv_status::timeout)
161 template<
typename _Rep,
typename _Period>
166 using __dur =
typename steady_clock::duration;
167 return wait_until(__lock,
168 steady_clock::now() +
169 chrono::__detail::ceil<__dur>(__rtime));
172 template<
typename _Rep,
typename _Period,
typename _Predicate>
178 using __dur =
typename steady_clock::duration;
179 return wait_until(__lock,
180 steady_clock::now() +
181 chrono::__detail::ceil<__dur>(__rtime),
187 {
return _M_cond.native_handle(); }
190#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
191 template<
typename _Dur>
196 auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
197 auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
199 __gthread_time_t __ts =
201 static_cast<std::time_t
>(__s.time_since_epoch().count()),
202 static_cast<long>(__ns.count())
205 _M_cond.wait_until(*__lock.mutex(), CLOCK_MONOTONIC, __ts);
207 return (steady_clock::now() < __atime
208 ? cv_status::no_timeout : cv_status::timeout);
212 template<
typename _Dur>
217 auto __s = chrono::time_point_cast<chrono::seconds>(__atime);
218 auto __ns = chrono::duration_cast<chrono::nanoseconds>(__atime - __s);
220 __gthread_time_t __ts =
222 static_cast<std::time_t
>(__s.time_since_epoch().count()),
223 static_cast<long>(__ns.count())
226 _M_cond.wait_until(*__lock.mutex(), __ts);
228 return (system_clock::now() < __atime
229 ? cv_status::no_timeout : cv_status::timeout);
248#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
257 template<
typename _Lock>
260 explicit _Unlock(_Lock& __lk) : _M_lock(__lk) { __lk.unlock(); }
262#pragma GCC diagnostic push
263#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
264 ~_Unlock()
noexcept(
false)
271 { __throw_exception_again; }
278#pragma GCC diagnostic pop
280 _Unlock(
const _Unlock&) =
delete;
281 _Unlock& operator=(
const _Unlock&) =
delete;
294 notify_one()
noexcept
297 _M_cond.notify_one();
301 notify_all()
noexcept
304 _M_cond.notify_all();
307 template<
typename _Lock>
313 _Unlock<_Lock> __unlock(__lock);
317 _M_cond.wait(__my_lock2);
321 template<
typename _Lock,
typename _Predicate>
323 wait(_Lock& __lock, _Predicate __p)
329 template<
typename _Lock,
typename _Clock,
typename _Duration>
331 wait_until(_Lock& __lock,
336 _Unlock<_Lock> __unlock(__lock);
340 return _M_cond.wait_until(__my_lock2, __atime);
343 template<
typename _Lock,
typename _Clock,
344 typename _Duration,
typename _Predicate>
346 wait_until(_Lock& __lock,
351 if (wait_until(__lock, __atime) == cv_status::timeout)
356 template<
typename _Lock,
typename _Rep,
typename _Period>
359 {
return wait_until(__lock, __clock_t::now() + __rtime); }
361 template<
typename _Lock,
typename _Rep,
362 typename _Period,
typename _Predicate>
364 wait_for(_Lock& __lock,
366 {
return wait_until(__lock, __clock_t::now() + __rtime,
std::move(__p)); }
368#ifdef __glibcxx_jthread
369 template <
class _Lock,
class _Predicate>
370 bool wait(_Lock& __lock,
374 if (__stoken.stop_requested())
384 if (__stoken.stop_requested())
390 _Unlock<_Lock> __unlock(__lock);
392 _M_cond.wait(__my_lock2);
397 template <
class _Lock,
class _Clock,
class _Duration,
class _Predicate>
398 bool wait_until(_Lock& __lock,
403 if (__stoken.stop_requested())
415 if (__stoken.stop_requested())
419 _Unlock<_Lock> __u(__lock);
421 const auto __status = _M_cond.wait_until(__my_lock2, __abs_time);
422 __stop = (__status == std::cv_status::timeout) || __stoken.stop_requested();
432 template <
class _Lock,
class _Rep,
class _Period,
class _Predicate>
433 bool wait_for(_Lock& __lock,
438 auto __abst = std::chrono::steady_clock::now() + __rel_time;
439 return wait_until(__lock,