mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-29 11:06:18 +00:00
os/threading: Add os_cond wrapper
This commit is contained in:
parent
7894039962
commit
76d8944765
|
@ -97,6 +97,54 @@ os_mutex_destroy(struct os_mutex *om)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Conditional variable.
|
||||
*
|
||||
*/
|
||||
struct os_cond
|
||||
{
|
||||
pthread_cond_t cond;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Init.
|
||||
*/
|
||||
static inline int
|
||||
os_cond_init(struct os_cond *oc)
|
||||
{
|
||||
return pthread_cond_init(&oc->cond, NULL);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Signal.
|
||||
*/
|
||||
static inline void
|
||||
os_cond_signal(struct os_cond *oc)
|
||||
{
|
||||
pthread_cond_signal(&oc->cond);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Wait.
|
||||
*/
|
||||
static inline void
|
||||
os_cond_wait(struct os_cond *oc, struct os_mutex *om)
|
||||
{
|
||||
pthread_cond_wait(&oc->cond, &om->mutex);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Clean up.
|
||||
*/
|
||||
static inline void
|
||||
os_cond_destroy(struct os_cond *oc)
|
||||
{
|
||||
pthread_cond_destroy(&oc->cond);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Thread.
|
||||
|
|
Loading…
Reference in a new issue