Commit 588b5225 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_global_mutex: common functions for process-wide mutexes

(cherry picked from commit e3c350269cf1b482d2f6842e5b31a83be27a1c40)
(kept core part only to minimize changes)
parent b98a024a
...@@ -430,4 +430,12 @@ class vlc_mutex_locker ...@@ -430,4 +430,12 @@ class vlc_mutex_locker
}; };
#endif #endif
enum {
VLC_MAX_MUTEX
};
VLC_EXPORT( void, vlc_global_mutex, ( unsigned, bool ) );
#define vlc_global_lock( n ) vlc_global_mutex( n, true )
#define vlc_global_unlock( n ) vlc_global_mutex( n, false )
#endif /* !_VLC_THREADS_H */ #endif /* !_VLC_THREADS_H */
...@@ -544,6 +544,7 @@ vlc_mutex_init_recursive ...@@ -544,6 +544,7 @@ vlc_mutex_init_recursive
vlc_mutex_lock vlc_mutex_lock
vlc_mutex_trylock vlc_mutex_trylock
vlc_mutex_unlock vlc_mutex_unlock
vlc_global_mutex
vlc_object_attach vlc_object_attach
vlc_object_create vlc_object_create
vlc_object_find vlc_object_find
......
...@@ -233,3 +233,22 @@ void vlc_thread_cancel (vlc_object_t *obj) ...@@ -233,3 +233,22 @@ void vlc_thread_cancel (vlc_object_t *obj)
if (priv->b_thread) if (priv->b_thread)
vlc_cancel (priv->thread_id); vlc_cancel (priv->thread_id);
} }
/*** Global locks ***/
void vlc_global_mutex (unsigned n, bool acquire)
{
static vlc_mutex_t locks[] = {
};
assert (n < (sizeof (locks) / sizeof (locks[0])));
vlc_mutex_t *lock = locks + n;
if (acquire)
vlc_mutex_lock (lock);
else
vlc_mutex_unlock (lock);
/* Compile-time assertion ;-) */
char enough_locks[(sizeof (locks) / sizeof (locks[0])) - VLC_MAX_MUTEX];
(void) enough_locks;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment