diff options
author | wm4 <wm4@nowhere> | 2014-01-31 19:50:25 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-01-31 19:50:25 +0100 |
commit | a17be5576fae918c683688a0e2bd2fd21b32d428 (patch) | |
tree | c46ceb404511ce0fbceadae24e85420bb7667321 /osdep/threads.c | |
parent | 2305ffcaba2b762825cc18cb35cec06c203e3821 (diff) | |
download | mpv-a17be5576fae918c683688a0e2bd2fd21b32d428.tar.bz2 mpv-a17be5576fae918c683688a0e2bd2fd21b32d428.tar.xz |
threads: add wrapper for initializing recursive mutexes
Damn this overly verbose pthread API.
Diffstat (limited to 'osdep/threads.c')
-rw-r--r-- | osdep/threads.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/osdep/threads.c b/osdep/threads.c index ac6dfbb0f0..0c31ffa40a 100644 --- a/osdep/threads.c +++ b/osdep/threads.c @@ -55,3 +55,14 @@ int mpthread_cond_timed_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, timespec_add_seconds(&ts, timeout); return pthread_cond_timedwait(cond, mutex, &ts); } + +// Helper to reduce boiler plate. +int mpthread_mutex_init_recursive(pthread_mutex_t *mutex) +{ + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + int r = pthread_mutex_init(mutex, &attr); + pthread_mutexattr_destroy(&attr); + return r; +} |