Condition variables for thread synchronization.
More...
Condition variables for thread synchronization.
Provides an abstraction from platform-specific condition variable implementations. Condition variables can be waited for with timeouts using relative durations and absolute time points.
Opaque type representing a condition variable.
Initializes a condition variable.
- Dynamic memory allocation
- Potentially allocates dynamic memory
- Precondition
condition_var
is not initialized
- Postcondition
- If successful,
condition_var
is initialized
- Returns
- EMBB_SUCCESS if successful
EMBB_ERROR otherwise
- Concurrency
- Not thread-safe
- See also
- embb_condition_destroy()
- Parameters
-
[out] | condition_var | Pointer to condition variable |
Unlocks mutex
and waits until the thread is woken up.
- Precondition
condition_var
is initialized and mutex
is locked by calling thread
- Postcondition
- If successful,
mutex
is locked by the calling thread
- Returns
- EMBB_SUCCESS if successful
EMBB_ERROR otherwise
- Concurrency
- Thread-safe
- See also
- embb_condition_notify_one(), embb_condition_notify_all(), embb_condition_wait_until(), embb_condition_wait_for()
- Note
- It is strongly recommended checking the condition in a loop in order to deal with spurious wakeups and situations where another thread has locked the mutex between notification and wakeup.
- Parameters
-
[in,out] | condition_var | Pointer to condition variable |
[in,out] | mutex | Pointer to mutex |
Unlocks mutex
and waits until the thread is woken up or time
has passed.
- Precondition
condition_var
is initialized and mutex
is locked by calling thread
- Postcondition
- If successful,
mutex
is locked by the calling thread
- Returns
- EMBB_SUCCESS if successful
EMBB_TIMEDOUT if mutex could not be locked until the specified point of time
EMBB_ERROR otherwise
- Concurrency
- Thread-safe
- See also
- embb_condition_notify_one(), embb_condition_notify_all(), embb_condition_wait(), embb_condition_wait_for()
- Note
- It is strongly recommended checking the condition in a loop in order to deal with spurious wakeups and situations where another thread has locked the mutex between notification and wakeup.
- Parameters
-
[in,out] | condition_var | Pointer to condition variable |
[in,out] | mutex | Pointer to mutex |
[in] | time | Point of time until the thread waits |
Unlocks mutex
and waits until the thread is woken up or duration
has passed.
- Precondition
condition_var
is initialized and mutex
is locked by calling thread
- Postcondition
- If successful,
mutex
is locked by the calling thread
- Returns
- EMBB_SUCCESS if successful
EMBB_TIMEDOUT if mutex could not be locked within the specified time span
EMBB_ERROR otherwise
- Concurrency
- Thread-safe
- See also
- embb_condition_notify_one(), embb_condition_notify_all(), embb_condition_wait(), embb_condition_wait_until()
- Note
- It is strongly recommended checking the condition in a loop in order to deal with spurious wakeups and situations where another thread has locked the mutex between notification and wakeup.
- Parameters
-
[in,out] | condition_var | Pointer to condition variable |
[in,out] | mutex | Pointer to mutex |
[in] | duration | Duration in microseconds the thread waits |