Go to the documentation of this file.
24 #ifndef RIOT_CONDITION_VARIABLE_HPP
25 #define RIOT_CONDITION_VARIABLE_HPP
82 template <class Predicate>
106 template <class Predicate>
117 template <class Rep, class Period>
119 const std::chrono::duration<Rep, Period>& rel_time);
129 template <class Rep, class Period, class Predicate>
131 const std::chrono::duration<Rep, Period>& rel_time,
146 template <
class Predicate>
153 template <
class Predicate>
158 if (
wait_until(lock, timeout_time) == cv_status::timeout) {
165 template <
class Rep,
class Period>
167 const std::chrono::duration
168 <Rep, Period>& timeout_duration) {
169 using namespace std::chrono;
170 using std::chrono::duration;
171 if (timeout_duration <= timeout_duration.zero()) {
172 return cv_status::timeout;
174 timex_t timeout, before, after;
175 auto s = duration_cast<seconds>(timeout_duration);
176 timeout.seconds = s.count();
178 = (duration_cast<microseconds>(timeout_duration - s)).count();
187 return cmp < 1 ? cv_status::no_timeout : cv_status::timeout;
190 template <
class Rep,
class Period,
class Predicate>
192 const std::chrono::duration
193 <Rep, Period>& timeout_duration,
195 return wait_until(lock, std::chrono::steady_clock::now() + timeout_duration,
201 #endif // RIOT_CONDITION_VARIABLE_HPP
void xtimer_now_timex(timex_t *out)
get the current system time into a timex_t
static uint64_t timex_uint64(const timex_t a)
Converts a timex timestamp to a 64 bit value.
Scheduler API definition.
static kernel_pid_t thread_getpid(void)
Returns the process ID of the currently running thread.
C++11 compliant implementation of unique lock.
C++11 chrono drop in replacement that adds the function now based on xtimer/timex.
priority_queue_node_t * first
first queue node
int timex_cmp(const timex_t a, const timex_t b)
Compares two timex timestamps.
A time point for timed wait, as clocks from the standard are not available on RIOT.
void notify_one() noexcept
Notify one thread waiting on this condition.
C++11 compliant implementation of mutex, uses the time point implemented in our chrono replacement in...
static void xtimer_set_wakeup(xtimer_t *timer, uint32_t offset, kernel_pid_t pid)
Set a timer that wakes up a thread.
data type for priority queues
void notify_all() noexcept
Notify all threads waiting on this condition variable.
cv_status wait_until(unique_lock< mutex > &lock, const time_point &timeout_time)
Block until woken up through the condition variable or a specified point in time is reached.
cv_status
Status for timeout-based calls of the condition variable.
cv_status wait_for(unique_lock< mutex > &lock, const std::chrono::duration< Rep, Period > &rel_time)
Blocks until woken up through the condition variable or when the thread has been blocked for a certai...
native_handle_type native_handle()
Returns the native handle of the condition variable.
void xtimer_remove(xtimer_t *timer)
remove a timer
C++11 compliant implementation of condition variable, uses the time point implemented in our chrono r...
timex_t timex_sub(const timex_t a, const timex_t b)
Subtracts two timestamps.
void wait(unique_lock< mutex > &lock) noexcept
Block until woken up through the condition variable.
xtimer interface definitions
C++11 mutex drop in replacement.