Mutex and condition variables.
More...
|
typedef struct vtm_mutex | vtm_mutex |
|
typedef struct vtm_cond | vtm_cond |
|
VTM_API vtm_mutex* vtm_mutex_new |
( |
void |
| ) |
|
Creates a new mutex.
- Returns
- a mutex handle
-
NULL if an error occured
VTM_API void vtm_mutex_free |
( |
vtm_mutex * |
mtx | ) |
|
Releases the mutex handle and all allocates resources.
- Parameters
-
mtx | the mutex which should be released |
VTM_API void vtm_mutex_lock |
( |
vtm_mutex * |
mtx | ) |
|
Locks the given mutex.
This call may block when the mutex is already locked by another thread.
- Parameters
-
mtx | the mutex which should be locked |
VTM_API void vtm_mutex_unlock |
( |
vtm_mutex * |
mtx | ) |
|
Unlocks the given mutex.
- Parameters
-
mtx | the mutex which should be unlocked |
VTM_API vtm_cond* vtm_cond_new |
( |
void |
| ) |
|
Creates a new condition variable.
- Returns
- a condition variable handle
-
NULL if an error occured
VTM_API void vtm_cond_free |
( |
vtm_cond * |
cond | ) |
|
Releases the condition variable and all allocates resources.
- Parameters
-
cond | the condition variable which should be released |
VTM_API void vtm_cond_wait |
( |
vtm_cond * |
cond, |
|
|
vtm_mutex * |
mtx |
|
) |
| |
Wait until given condition variable is signaled.
The mutex must be already locked by the current thread when this method is called. The mutex is unlocked while waiting and is re-locked when the call returns.
Due to spurious wakeups on some platforms, the condition should always be checked again after this call has returned.
- Parameters
-
cond | the condition variable on which the wait is performed |
mtx | the mutex which is used |
VTM_API void vtm_cond_signal |
( |
vtm_cond * |
cond | ) |
|
Wakes up one thread that is waiting on this condition variable.
- Parameters
-
cond | the condition variable which should be signaled |
VTM_API void vtm_cond_signal_all |
( |
vtm_cond * |
cond | ) |
|
Wakes up all threads that are waiting on this condition.
- Parameters
-
cond | the condition variable which should be signaled |