|
Macros | |
| #define | SYS_COND_CAPACITY 32 |
| Maximum number of condition variables available in static-pool implementations. | |
Typedefs | |
| typedef struct sys_cond_t | sys_cond_t |
| Condition variable. | |
Lifecycle | |
| sys_cond_t * | sys_cond_init (void) |
| Initialize a new condition variable. More... | |
| void | sys_cond_deinit (sys_cond_t *cond) |
| Deinitialize a condition variable. More... | |
Methods | |
| bool | sys_cond_wait (sys_cond_t *cond, sys_mutex_t *mutex) |
| Wait on a condition variable. More... | |
| bool | sys_cond_timedwait (sys_cond_t *cond, sys_mutex_t *mutex, uint32_t timeout_ms) |
| Wait on a condition variable with timeout. More... | |
| bool | sys_cond_signal (sys_cond_t *cond) |
| Signal one waiting thread. More... | |
| bool | sys_cond_broadcast (sys_cond_t *cond) |
| Signal all waiting threads. More... | |
| bool sys_cond_broadcast | ( | sys_cond_t * | cond | ) |
Signal all waiting threads.
| cond | Pointer to the condition variable to broadcast |
Wakes up all threads waiting on the condition variable. If no threads are waiting, this function has no effect. The associated mutex should be locked when calling this function for predictable behavior.
| void sys_cond_deinit | ( | sys_cond_t * | cond | ) |
Deinitialize a condition variable.
| cond | Pointer to the condition variable to deinitialize |
Releases all resources associated with the condition variable and renders it unusable. No threads should be waiting on the condition variable when this function is called.
| sys_cond_t* sys_cond_init | ( | void | ) |
Initialize a new condition variable.
Creates and initializes a new condition variable for thread synchronization. The condition variable is ready for use with wait/signal operations. The returned condition variable must be deinitialized with sys_cond_deinit()
| bool sys_cond_signal | ( | sys_cond_t * | cond | ) |
Signal one waiting thread.
| cond | Pointer to the condition variable to signal |
Wakes up one thread waiting on the condition variable. If no threads are waiting, this function has no effect. The associated mutex should be locked when calling this function for predictable behavior.
| bool sys_cond_timedwait | ( | sys_cond_t * | cond, |
| sys_mutex_t * | mutex, | ||
| uint32_t | timeout_ms | ||
| ) |
Wait on a condition variable with timeout.
| cond | Pointer to the condition variable to wait on |
| mutex | Pointer to the mutex that must be locked by the calling thread |
| timeout_ms | Timeout in milliseconds (0 = no timeout) |
Like sys_cond_wait() but returns after timeout_ms milliseconds if not signaled. Returns true if signaled, false if timeout or error occurred.
| bool sys_cond_wait | ( | sys_cond_t * | cond, |
| sys_mutex_t * | mutex | ||
| ) |
Wait on a condition variable.
| cond | Pointer to the condition variable to wait on |
| mutex | Pointer to the mutex that must be locked by the calling thread |
Atomically releases the mutex and waits for the condition variable to be signaled. Upon return, the mutex is reacquired. The mutex must be locked by the calling thread before calling this function.