mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
libobs/util: pthread_mutex_init_recursive helper
Add helper for creating a recursive mutex because it's easy to forget to destroy the pthread_mutexattr_t.
This commit is contained in:
parent
0b70b479a1
commit
b9657f6239
|
@ -53,6 +53,22 @@ static inline void pthread_mutex_init_value(pthread_mutex_t *mutex)
|
|||
*mutex = init_val;
|
||||
}
|
||||
|
||||
static inline int pthread_mutex_init_recursive(pthread_mutex_t *mutex)
|
||||
{
|
||||
pthread_mutexattr_t attr;
|
||||
int ret = pthread_mutexattr_init(&attr);
|
||||
if (ret == 0) {
|
||||
ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (ret == 0) {
|
||||
ret = pthread_mutex_init(mutex, &attr);
|
||||
}
|
||||
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
enum os_event_type {
|
||||
OS_EVENT_TYPE_AUTO,
|
||||
OS_EVENT_TYPE_MANUAL,
|
||||
|
|
Loading…
Reference in a new issue