Rtos
Data Structures | |
class | ConditionVariable |
This class provides a safe way to wait for or send notifications of condition changes. More... | |
Namespaces | |
namespace | rtos::Kernel |
Functions in the Kernel namespace control RTOS kernel information. | |
Modules | |
EventFlags class | |
Mail class | |
MemoryPool class | |
Mutex class | |
Idle hook function | |
RtosTimer class | |
Semaphore class | |
Thread class | |
Typedefs | |
typedef mbed::ScopedLock< Mutex > | ScopedMutexLock |
Typedef for the mutex lock. | |
Functions | |
void | wait () |
Wait for a notification. | |
bool | wait_until (uint64_t millisec) |
Wait for a notification until specified time. | |
bool | wait_for (uint32_t millisec) |
Wait for a notification or timeout. | |
void | notify_one () |
Notify one waiter on this condition variable that a condition changed. | |
void | notify_all () |
Notify all waiters on this condition variable that a condition changed. | |
~ConditionVariable () | |
ConditionVariable destructor. |
Typedef Documentation
typedef mbed::ScopedLock<Mutex> ScopedMutexLock |
Typedef for the mutex lock.
Usage:
void foo(Mutex &m) { ScopedMutexLock lock(m); // Mutex lock protects code in this block }
Function Documentation
void notify_all | ( | ) | [inherited] |
Notify all waiters on this condition variable that a condition changed.
- Note:
- - The thread calling this function must be the owner of the ConditionVariable's mutex
- You cannot call this function from ISR context.
Definition at line 94 of file ConditionVariable.cpp.
void notify_one | ( | ) | [inherited] |
Notify one waiter on this condition variable that a condition changed.
- Note:
- - The thread calling this function must be the owner of the ConditionVariable's mutex
- You cannot call this function from ISR context.
Definition at line 85 of file ConditionVariable.cpp.
void wait | ( | ) | [inherited] |
Wait for a notification.
Wait until a notification occurs.
- Note:
- - The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- - Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met
Example:
mutex.lock();
while (!condition_met) {
cond.wait();
}
function_to_handle_condition();
mutex.unlock();
- Note:
- You cannot call this function from ISR context.
Definition at line 41 of file ConditionVariable.cpp.
bool wait_for | ( | uint32_t | millisec ) | [inherited] |
Wait for a notification or timeout.
- Parameters:
-
millisec timeout value or osWaitForever in case of no time-out.
- Returns:
- true if a timeout occurred, false otherwise.
- Note:
- - The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- - Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met
Example:
mutex.lock(); while (!condition_met) { cond.wait_for(MAX_SLEEP_TIME); if (!condition_met) { do_other_work_while_condition_false(); } } if (condition_met) { function_to_handle_condition(); } mutex.unlock();
- Note:
- You cannot call this function from ISR context.
Definition at line 46 of file ConditionVariable.cpp.
bool wait_until | ( | uint64_t | millisec ) | [inherited] |
Wait for a notification until specified time.
- Parameters:
-
millisec absolute end time referenced to Kernel::get_ms_count()
- Returns:
- true if a timeout occurred, false otherwise.
- Note:
- - The thread calling this function must be the owner of the ConditionVariable's mutex and it must be locked exactly once
- - Spurious notifications can occur so the caller of this API should check to make sure the condition they are waiting on has been met
Example:
mutex.lock(); uint64_t end_time = Kernel::get_ms_count() + COND_WAIT_TIMEOUT; while (!condition_met) { if (cond.wait_until(end_time)) { break; } } if (condition_met) { function_to_handle_condition(); } mutex.unlock();
- Note:
- You cannot call this function from ISR context.
Definition at line 67 of file ConditionVariable.cpp.
~ConditionVariable | ( | ) | [inherited] |
ConditionVariable destructor.
- Note:
- You cannot call this function from ISR context.
Definition at line 148 of file ConditionVariable.cpp.
Generated on Tue Jul 12 2022 12:22:40 by
