16#ifndef CMSIS_PLUS_ESTD_CONDITION_VARIABLE_
17#define CMSIS_PLUS_ESTD_CONDITION_VARIABLE_
22#pragma GCC diagnostic push
24#pragma clang diagnostic ignored "-Wgnu-include-next"
26#include_next <condition_variable>
27#pragma GCC diagnostic pop
36#pragma GCC diagnostic push
38#pragma clang diagnostic ignored "-Wc++98-compat"
102 template <class Predicate_T>
106 template <class Clock_T, class Duration_T>
110 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time);
112 template <class Clock_T, class Duration_T, class Predicate_T>
115 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time,
118 template <class Rep_T, class Period_T>
121 const
std::chrono::duration<Rep_T, Period_T>& rel_time);
123 template <class Rep_T, class Period_T, class Predicate_T>
126 const
std::chrono::duration<Rep_T, Period_T>& rel_time,
159 template <class Lock_T>
163 template <class Lock_T, class Predicate_T>
165 wait (Lock_T& lock, Predicate_T pred);
167 template <class Lock_T, class Clock_T, class Duration_T>
171 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time);
173 template <class Lock_T, class Clock_T, class Duration_T,
177 const
std::chrono::time_point<Clock_T, Duration_T>& abs_time,
180 template <class Lock_T, class Rep_T, class Period_T>
183 const
std::chrono::duration<Rep_T, Period_T>& rel_time);
185 template <class Lock_T, class Rep_T, class Period_T, class Predicate_T>
188 const
std::chrono::duration<Rep_T, Period_T>& rel_time,
213 template <
class Predicate_T>
221#pragma GCC diagnostic push
222#if defined(__clang__)
223#elif defined(__GNUC__)
224#pragma GCC diagnostic ignored "-Waggregate-return"
227 template <
class Clock_T,
class Duration_T>
230 std::unique_lock<mutex>& lock,
231 const std::chrono::time_point<Clock_T, Duration_T>& abs_time)
233 using namespace std::chrono;
234 using clock = Clock_T;
237 wait_for (lock, abs_time - Clock_T::now ());
239 Clock_T::now () < abs_time ?
245 = std::chrono::duration_cast<Native_clock::duration> (
246 abs_time - clock::now ());
251#pragma GCC diagnostic pop
253 template <
class Clock_T,
class Duration_T,
class Predicate_T>
256 std::unique_lock<mutex>& lock,
257 const std::chrono::time_point<Clock_T, Duration_T>& abs_time,
268#pragma GCC diagnostic push
269#if defined(__clang__)
270#elif defined(__GNUC__)
271#pragma GCC diagnostic ignored "-Waggregate-return"
274 template <
class Rep_T,
class Period_T>
277 std::unique_lock<mutex>& lock,
278 const std::chrono::duration<Rep_T, Period_T>& rel_time)
280 using namespace std::chrono;
282 if (rel_time <= rel_time.zero ())
296 (*(lock.mutex ()->native_handle ())), ticks);
303 template <
class Rep_T,
class Period_T,
class Predicate_T>
306 std::unique_lock<mutex>& lock,
307 const std::chrono::duration<Rep_T, Period_T>& rel_time,
314#pragma GCC diagnostic pop
331 std::lock_guard<mutex> lock (*
mx_);
338 std::lock_guard<mutex> lock (*
mx_);
342#pragma GCC diagnostic push
343#if defined(__clang__)
344#pragma clang diagnostic ignored "-Wreserved-identifier"
348 template <
class Lock_T>
355#pragma GCC diagnostic pop
357 template <
class Lock_T>
361 std::shared_ptr<mutex> mx =
mx_;
362 std::unique_lock<mutex> lk (*mx);
364 std::unique_ptr<Lock_T, __lock_external> lxx (&lock);
365 std::lock_guard<std::unique_lock<mutex>> lx (lk, std::adopt_lock);
372 template <
class Lock_T,
class Predicate_T>
380 template <
class Lock_T,
class Clock_T,
class Duration_T>
384 const std::chrono::time_point<Clock_T, Duration_T>& abs_time)
386 std::shared_ptr<mutex> mx =
mx_;
387 std::unique_lock<mutex> lk (*mx);
389 std::unique_ptr<Lock_T, __lock_external> lxx (&lock);
390 std::lock_guard<std::unique_lock<mutex>> lx (lk, std::adopt_lock);
397 template <
class Lock_T,
class Clock_T,
class Duration_T,
class Predicate_T>
401 const std::chrono::time_point<Clock_T, Duration_T>& abs_time,
414 template <
class Lock_T,
class Rep_T,
class Period_T>
417 Lock_T& lock,
const std::chrono::duration<Rep_T, Period_T>& rel_time)
422 template <
class Lock_T,
class Rep_T,
class Period_T,
class Predicate_T>
425 Lock_T& lock,
const std::chrono::duration<Rep_T, Period_T>& rel_time,
436#pragma GCC diagnostic pop
438#if defined(OS_HAS_STD_THREADS)
std::ratio< 1, os::rtos::clock_systick::frequency_hz > period
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)