riot::condition_variable Class Reference

C++11 compliant implementation of condition variable, uses the time point implemented in our chrono replacement instead of the specified one. More...

Detailed Description

C++11 compliant implementation of condition variable, uses the time point implemented in our chrono replacement instead of the specified one.

See also
std::condition_variable

Definition at line 52 of file condition_variable.hpp.

#include <condition_variable.hpp>

Public Types

using native_handle_type = priority_queue_t *
 The native handle type used by the condition variable.
 

Public Member Functions

void notify_one () noexcept
 Notify one thread waiting on this condition.
 
void notify_all () noexcept
 Notify all threads waiting on this condition variable.
 
void wait (unique_lock< mutex > &lock) noexcept
 Block until woken up through the condition variable. More...
 
template<class Predicate >
void wait (unique_lock< mutex > &lock, Predicate pred)
 Block until woken up through the condition variable and a predicate is fulfilled. More...
 
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. More...
 
template<class Predicate >
bool wait_until (unique_lock< mutex > &lock, const time_point &timeout_time, Predicate pred)
 Block until woken up through the condition variable and a predicate is fulfilled or a specified point in time is reached. More...
 
template<class Rep , class Period >
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 certain time. More...
 
template<class Rep , class Period , class Predicate >
bool wait_for (unique_lock< mutex > &lock, const std::chrono::duration< Rep, Period > &rel_time, Predicate pred)
 Blocks until woken up through the condition variable and a predicate is fulfilled or when the thread has been blocked for a certain time. More...
 
native_handle_type native_handle ()
 Returns the native handle of the condition variable.
 

Member Function Documentation

◆ wait() [1/2]

void riot::condition_variable::wait ( unique_lock< mutex > &  lock)
noexcept

Block until woken up through the condition variable.

Parameters
lockA lock that is locked by the current thread.

◆ wait() [2/2]

template<class Predicate >
void riot::condition_variable::wait ( unique_lock< mutex > &  lock,
Predicate  pred 
)

Block until woken up through the condition variable and a predicate is fulfilled.

Parameters
lockA lock that is locked by the current thread.
predA predicate that returns a bool to signify if the thread should continue to wait when woken up through the cv.

Definition at line 147 of file condition_variable.hpp.

◆ wait_for() [1/2]

template<class Rep , class Period >
cv_status riot::condition_variable::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 certain time.

Parameters
lockA lock that is locked by the current thread.
rel_timeThe maximum time spent blocking.
Returns
A status to signify if woken up due to a timeout or the cv.

Definition at line 166 of file condition_variable.hpp.

◆ wait_for() [2/2]

template<class Rep , class Period , class Predicate >
bool riot::condition_variable::wait_for ( unique_lock< mutex > &  lock,
const std::chrono::duration< Rep, Period > &  rel_time,
Predicate  pred 
)
inline

Blocks until woken up through the condition variable and a predicate is fulfilled or when the thread has been blocked for a certain time.

Parameters
lockA lock that is locked by the current thread.
rel_timeThe maximum time spent blocking.
predA predicate that returns a bool to signify if the thread should continue to wait when woken up through the cv.
Returns
Result of the pred when the function returns.

Definition at line 191 of file condition_variable.hpp.

◆ wait_until() [1/2]

cv_status riot::condition_variable::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.

The lock is reacquired either way.

Parameters
lockA lock that is locked by the current thread.
timeout_timePoint in time when the thread is woken up independently of the condition variable.
Returns
A status to signify if woken up due to a timeout or the cv.

◆ wait_until() [2/2]

template<class Predicate >
bool riot::condition_variable::wait_until ( unique_lock< mutex > &  lock,
const time_point timeout_time,
Predicate  pred 
)

Block until woken up through the condition variable and a predicate is fulfilled or a specified point in time is reached.

The lock is reacquired either way.

Parameters
lockA lock that is locked by the current thread.
timeout_timePoint in time when the thread is woken up independently of the condition variable.
predA predicate that returns a bool to signify if the thread should continue to wait when woken up through the cv.
Returns
Result of the pred when the function returns.

Definition at line 154 of file condition_variable.hpp.


The documentation for this class was generated from the following file: