32#ifndef CMSIS_PLUS_ESTD_CONDITION_VARIABLE_
33#define CMSIS_PLUS_ESTD_CONDITION_VARIABLE_
38#pragma GCC diagnostic push
40#pragma clang diagnostic ignored "-Wgnu-include-next"
42#include_next <condition_variable>
43#pragma GCC diagnostic pop
52#pragma GCC diagnostic push
55#pragma clang diagnostic ignored "-Wc++98-compat"
120 template<class Predicate_T>
124 template<class Clock_T, class Duration_T>
128 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time);
130 template<class Clock_T, class Duration_T, class Predicate_T>
134 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time,
137 template<class Rep_T, class Period_T>
140 const
std::chrono::duration<Rep_T, Period_T>& rel_time);
142 template<class Rep_T, class Period_T, class Predicate_T>
145 const
std::chrono::duration<Rep_T, Period_T>& rel_time,
180 template<class Lock_T>
184 template<class Lock_T, class Predicate_T>
186 wait (Lock_T& lock, Predicate_T pred);
188 template<class Lock_T, class Clock_T, class Duration_T>
192 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time);
194 template<class Lock_T, class Clock_T, class Duration_T, class Predicate_T>
198 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time,
201 template<class Lock_T, class Rep_T, class Period_T>
204 const
std::chrono::duration<Rep_T, Period_T>& rel_time);
206 template<class Lock_T, class Rep_T, class Period_T, class Predicate_T>
209 const
std::chrono::duration<Rep_T, Period_T>& rel_time,
240 template<
class Predicate_T>
248#pragma GCC diagnostic push
249#pragma GCC diagnostic ignored "-Waggregate-return"
251 template<
class Clock_T,
class Duration_T>
254 std::unique_lock<mutex>& lock,
255 const std::chrono::time_point<Clock_T, Duration_T>& abs_time)
257 using namespace std::chrono;
258 using clock = Clock_T;
261 wait_for (lock, abs_time - Clock_T::now ());
263 Clock_T::now () < abs_time ?
274#pragma GCC diagnostic pop
276 template<
class Clock_T,
class Duration_T,
class Predicate_T>
279 std::unique_lock<mutex>& lock,
280 const std::chrono::time_point<Clock_T, Duration_T>& abs_time,
291#pragma GCC diagnostic push
292#pragma GCC diagnostic ignored "-Waggregate-return"
294 template<
class Rep_T,
class Period_T>
297 std::unique_lock<mutex>& lock,
298 const std::chrono::duration<Rep_T, Period_T>& rel_time)
300 using namespace std::chrono;
302 if (rel_time <= rel_time.zero ())
314 (*(lock.mutex ()->native_handle ())),
322 template<
class Rep_T,
class Period_T,
class Predicate_T>
326 std::unique_lock<mutex>& lock,
327 const std::chrono::duration<Rep_T, Period_T>& rel_time,
334#pragma GCC diagnostic pop
343 { std::make_shared<mutex> () }
357 std::lock_guard<mutex> lock (*
mx_);
364 std::lock_guard<mutex> lock (*
mx_);
370 template<
class Lock_T>
378 template<
class Lock_T>
382 std::shared_ptr<mutex> mx =
mx_;
383 std::unique_lock<mutex> lk (*mx);
385 std::unique_ptr<Lock_T, __lock_external> lxx(&lock);
386 std::lock_guard<std::unique_lock<mutex> > lx (lk, std::adopt_lock);
393 template<
class Lock_T,
class Predicate_T>
401 template<
class Lock_T,
class Clock_T,
class Duration_T>
405 const std::chrono::time_point<Clock_T, Duration_T>& abs_time)
407 std::shared_ptr<mutex> mx =
mx_;
408 std::unique_lock<mutex> lk (*mx);
410 std::unique_ptr<Lock_T, __lock_external> lxx(&lock);
411 std::lock_guard<std::unique_lock<mutex> > lx (lk, std::adopt_lock);
418 template<
class Lock_T,
class Clock_T,
class Duration_T,
class Predicate_T>
422 const std::chrono::time_point<Clock_T, Duration_T>& abs_time,
436 template<
class Lock_T,
class Rep_T,
class Period_T>
439 Lock_T& lock,
const std::chrono::duration<Rep_T, Period_T>& rel_time)
444 template<
class Lock_T,
class Rep_T,
class Period_T,
class Predicate_T>
447 Lock_T& lock,
const std::chrono::duration<Rep_T, Period_T>& rel_time,
458#pragma GCC diagnostic pop
460#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)