17#ifndef CMSIS_PLUS_ESTD_CONDITION_VARIABLE_
18#define CMSIS_PLUS_ESTD_CONDITION_VARIABLE_
23#pragma GCC diagnostic push
25#pragma clang diagnostic ignored "-Wgnu-include-next"
27#include_next <condition_variable>
28#pragma GCC diagnostic pop
37#pragma GCC diagnostic push
39#pragma clang diagnostic ignored "-Wc++98-compat"
104 template<class Predicate_T>
108 template<class Clock_T, class Duration_T>
112 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time);
114 template<class Clock_T, class Duration_T, class Predicate_T>
118 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time,
121 template<class Rep_T, class Period_T>
124 const
std::chrono::duration<Rep_T, Period_T>& rel_time);
126 template<class Rep_T, class Period_T, class Predicate_T>
129 const
std::chrono::duration<Rep_T, Period_T>& rel_time,
164 template<class Lock_T>
168 template<class Lock_T, class Predicate_T>
170 wait (Lock_T& lock, Predicate_T pred);
172 template<class Lock_T, class Clock_T, class Duration_T>
176 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time);
178 template<class Lock_T, class Clock_T, class Duration_T, class Predicate_T>
182 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time,
185 template<class Lock_T, class Rep_T, class Period_T>
188 const
std::chrono::duration<Rep_T, Period_T>& rel_time);
190 template<class Lock_T, class Rep_T, class Period_T, class Predicate_T>
193 const
std::chrono::duration<Rep_T, Period_T>& rel_time,
222 template<
class Predicate_T>
230#pragma GCC diagnostic push
231#if defined(__clang__)
232#elif defined(__GNUC__)
233#pragma GCC diagnostic ignored "-Waggregate-return"
236 template<
class Clock_T,
class Duration_T>
239 std::unique_lock<mutex>& lock,
240 const std::chrono::time_point<Clock_T, Duration_T>& abs_time)
242 using namespace std::chrono;
243 using clock = Clock_T;
246 wait_for (lock, abs_time - Clock_T::now ());
248 Clock_T::now () < abs_time ?
259#pragma GCC diagnostic pop
261 template<
class Clock_T,
class Duration_T,
class Predicate_T>
264 std::unique_lock<mutex>& lock,
265 const std::chrono::time_point<Clock_T, Duration_T>& abs_time,
276#pragma GCC diagnostic push
277#if defined(__clang__)
278#elif defined(__GNUC__)
279#pragma GCC diagnostic ignored "-Waggregate-return"
282 template<
class Rep_T,
class Period_T>
285 std::unique_lock<mutex>& lock,
286 const std::chrono::duration<Rep_T, Period_T>& rel_time)
288 using namespace std::chrono;
290 if (rel_time <= rel_time.zero ())
302 (*(lock.mutex ()->native_handle ())),
310 template<
class Rep_T,
class Period_T,
class Predicate_T>
314 std::unique_lock<mutex>& lock,
315 const std::chrono::duration<Rep_T, Period_T>& rel_time,
322#pragma GCC diagnostic pop
331 { std::make_shared<mutex> () }
343 std::lock_guard<mutex> lock (*
mx_);
350 std::lock_guard<mutex> lock (*
mx_);
354#pragma GCC diagnostic push
355#if defined(__clang__)
356#pragma clang diagnostic ignored "-Wreserved-identifier"
360 template<
class Lock_T>
367#pragma GCC diagnostic pop
369 template<
class Lock_T>
373 std::shared_ptr<mutex> mx =
mx_;
374 std::unique_lock<mutex> lk (*mx);
376 std::unique_ptr<Lock_T, __lock_external> lxx(&lock);
377 std::lock_guard<std::unique_lock<mutex> > lx (lk, std::adopt_lock);
384 template<
class Lock_T,
class Predicate_T>
392 template<
class Lock_T,
class Clock_T,
class Duration_T>
396 const std::chrono::time_point<Clock_T, Duration_T>& abs_time)
398 std::shared_ptr<mutex> mx =
mx_;
399 std::unique_lock<mutex> lk (*mx);
401 std::unique_ptr<Lock_T, __lock_external> lxx(&lock);
402 std::lock_guard<std::unique_lock<mutex> > lx (lk, std::adopt_lock);
409 template<
class Lock_T,
class Clock_T,
class Duration_T,
class Predicate_T>
413 const std::chrono::time_point<Clock_T, Duration_T>& abs_time,
427 template<
class Lock_T,
class Rep_T,
class Period_T>
430 Lock_T& lock,
const std::chrono::duration<Rep_T, Period_T>& rel_time)
435 template<
class Lock_T,
class Rep_T,
class Period_T,
class Predicate_T>
438 Lock_T& lock,
const std::chrono::duration<Rep_T, Period_T>& rel_time,
449#pragma GCC diagnostic pop
451#if defined(OS_HAS_STD_THREADS)
std::ratio< 1, os::rtos::clock_systick::frequency_hz > period
std::ratio type representing the tick period of the clock, in seconds
std::chrono::time_point< systick_clock > time_point
basic time_point type of clock
static time_point now() noexcept
std::chrono::duration< rep, period > duration
basic duration type of clock
void notify_one() noexcept
void notify_all() noexcept
std::shared_ptr< mutex > mx_
condition_variable_any(const condition_variable_any &)=delete
cv_status wait_for(Lock_T &lock, const std::chrono::duration< Rep_T, Period_T > &rel_time)
~condition_variable_any()
cv_status wait_until(Lock_T &lock, const std::chrono::time_point< Clock_T, Duration_T > &abs_time)
condition_variable & operator=(const condition_variable &)=delete
void wait(std::unique_lock< mutex > &lock)
condition_variable(const condition_variable &)=delete
cv_status wait_until(std::unique_lock< mutex > &lock, const std::chrono::time_point< Clock_T, Duration_T > &abs_time)
native_handle_type native_handle()
void notify_one() noexcept
cv_status wait_for(std::unique_lock< mutex > &lock, const std::chrono::duration< Rep_T, Period_T > &rel_time)
void notify_all() noexcept
POSIX compliant condition variable.
result_t timed_wait(mutex &mutex, clock::duration_t timeout)
Timed wait for a condition variable to be notified.
void notify_all_at_thread_exit(condition_variable &cond, std::unique_lock< mutex > lk)
port::clock::duration_t duration_t
Type of variables holding clock durations.
constexpr std::enable_if< std::chrono::__is_duration< _To >::value, _To >::type ceil(std::chrono::duration< Rep_T, Period_T > d)
void operator()(Lock_T *lk)