VLC 4.0.0-dev

Thread primitive declarations. More...

Include dependency graph for vlc_threads.h:

Go to the source code of this file.

Data Structures

struct  vlc_thread_t
 Thread handle. More...
 
struct  vlc_mutex_t
 Mutex. More...
 
struct  vlc_cond_t
 Condition variable. More...
 
struct  vlc_sem_t
 Semaphore. More...
 
struct  vlc_latch_t
 Latch. More...
 
struct  vlc_queuedmutex_t
 
struct  vlc_once_t
 One-time initialization. More...
 

Macros

#define LIBVLC_USE_PTHREAD   1
 Whether LibVLC threads are based on POSIX threads. More...
 
#define LIBVLC_USE_PTHREAD_CLEANUP   1
 Whether LibVLC thread cancellation is based on POSIX threads. More...
 
#define VLC_THREAD_CANCELED   PTHREAD_CANCELED
 Return value of a canceled thread. More...
 
#define VLC_STATIC_MUTEX
 Static initializer for (static) mutex. More...
 
#define vlc_mutex_assert(m)   assert(vlc_mutex_held(m))
 Asserts that a mutex is locked by the calling thread. More...
 
#define VLC_STATIC_COND   { NULL, VLC_STATIC_MUTEX }
 Static initializer for (static) condition variable. More...
 
#define VLC_STATIC_QUEUEDMUTEX   { ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0), ATOMIC_VAR_INIT(0) }
 
#define vlc_queuedmutex_assert(m)   assert(vlc_queuedmutex_held(m))
 
#define VLC_STATIC_ONCE   { ATOMIC_VAR_INIT(0) }
 Static initializer for one-time initialization. More...
 
#define vlc_once_begin(once)   vlc_once_begin_inline(once)
 
#define VLC_HARD_MIN_SLEEP   VLC_TICK_FROM_MS(10) /* 10 milliseconds = 1 tick at 100Hz */
 
#define VLC_SOFT_MIN_SLEEP   VLC_TICK_FROM_SEC(9) /* 9 seconds */
 
#define VLC_TIMER_DISARM   (0)
 
#define VLC_TIMER_FIRE_ONCE   (0)
 
#define vlc_cleanup_push(routine, arg)   pthread_cleanup_push (routine, arg)
 Registers a thread cancellation handler. More...
 
#define vlc_cleanup_pop()   pthread_cleanup_pop (0)
 Unregisters the last cancellation handler. More...
 
#define vlc_global_lock(n)   vlc_global_mutex(n, true)
 Acquires a global mutex. More...
 
#define vlc_global_unlock(n)   vlc_global_mutex(n, false)
 Releases a global mutex. More...
 

Typedefs

typedef pthread_key_t vlc_threadvar_t
 Thread-local key handle. More...
 
typedef struct vlc_timervlc_timer_t
 Threaded timer handle. More...
 
typedef struct vlc_cleanup_t vlc_cleanup_t
 

Enumerations

enum  {
  VLC_AVCODEC_MUTEX = 0 , VLC_GCRYPT_MUTEX , VLC_XLIB_MUTEX , VLC_MOSAIC_MUTEX ,
  VLC_MAX_MUTEX
}
 

Functions

void vlc_testcancel (void)
 Issues an explicit deferred cancellation point. More...
 
void vlc_mutex_init (vlc_mutex_t *)
 Initializes a fast mutex. More...
 
void vlc_mutex_init_recursive (vlc_mutex_t *)
 Initializes a recursive mutex. More...
 
void vlc_mutex_lock (vlc_mutex_t *)
 Acquires a mutex. More...
 
int vlc_mutex_trylock (vlc_mutex_t *)
 Tries to acquire a mutex. More...
 
void vlc_mutex_unlock (vlc_mutex_t *)
 Releases a mutex. More...
 
bool vlc_mutex_held (const vlc_mutex_t *)
 Checks if a mutex is locked. More...
 
void vlc_cond_init (vlc_cond_t *)
 Initializes a condition variable. More...
 
void vlc_cond_signal (vlc_cond_t *)
 Wakes up one thread waiting on a condition variable. More...
 
void vlc_cond_broadcast (vlc_cond_t *)
 Wakes up all threads waiting on a condition variable. More...
 
void vlc_cond_wait (vlc_cond_t *cond, vlc_mutex_t *mutex)
 Waits on a condition variable. More...
 
int vlc_cond_timedwait (vlc_cond_t *cond, vlc_mutex_t *mutex, vlc_tick_t deadline)
 Waits on a condition variable up to a certain date. More...
 
int vlc_cond_timedwait_daytime (vlc_cond_t *, vlc_mutex_t *, time_t)
 
void vlc_sem_init (vlc_sem_t *, unsigned count)
 Initializes a semaphore. More...
 
int vlc_sem_post (vlc_sem_t *)
 Increments the value of a semaphore. More...
 
void vlc_sem_wait (vlc_sem_t *)
 Waits on a semaphore. More...
 
int vlc_sem_trywait (vlc_sem_t *sem)
 Tries to decrement a semaphore. More...
 
int vlc_sem_timedwait (vlc_sem_t *sem, vlc_tick_t deadline)
 Waits on a semaphore within a deadline. More...
 
void vlc_latch_init (vlc_latch_t *, size_t value)
 Initializes a latch. More...
 
void vlc_latch_count_down (vlc_latch_t *, size_t n)
 Decrements the value of a latch. More...
 
void vlc_latch_count_down_and_wait (vlc_latch_t *, size_t n)
 Decrements the value of a latch and waits on it. More...
 
bool vlc_latch_is_ready (const vlc_latch_t *latch)
 Checks if a latch is ready. More...
 
void vlc_latch_wait (vlc_latch_t *)
 Waits on a latch. More...
 
void vlc_queuedmutex_init (vlc_queuedmutex_t *m)
 
void vlc_queuedmutex_lock (vlc_queuedmutex_t *m)
 
void vlc_queuedmutex_unlock (vlc_queuedmutex_t *m)
 
bool vlc_queuedmutex_held (vlc_queuedmutex_t *m)
 Checks if a queued mutex is locked. More...
 
bool vlc_once_begin (vlc_once_t *restrict once)
 Begins a one-time initialization. More...
 
static bool vlc_once_begin_inline (vlc_once_t *restrict once)
 
void vlc_once_complete (vlc_once_t *restrict once)
 Completes a one-time initialization. More...
 
static void vlc_once (vlc_once_t *restrict once, void(*cb)(void *), void *opaque)
 Executes a function one time. More...
 
int vlc_threadvar_create (vlc_threadvar_t *key, void(*destr)(void *))
 Allocates a thread-specific variable. More...
 
void vlc_threadvar_delete (vlc_threadvar_t *)
 Deallocates a thread-specific variable. More...
 
int vlc_threadvar_set (vlc_threadvar_t key, void *value)
 Sets a thread-specific variable. More...
 
void * vlc_threadvar_get (vlc_threadvar_t)
 Gets the value of a thread-local variable for the calling thread. More...
 
int vlc_clone (vlc_thread_t *th, void *(*entry)(void *), void *data)
 Creates and starts a new thread. More...
 
void vlc_thread_set_name (const char *name)
 Set the thread name of the current thread. More...
 
void vlc_cancel (vlc_thread_t)
 Marks a thread as cancelled. More...
 
void vlc_join (vlc_thread_t th, void **result)
 Waits for a thread to complete (if needed), then destroys it. More...
 
int vlc_savecancel (void)
 Disables thread cancellation. More...
 
void vlc_restorecancel (int state)
 Restores the cancellation state. More...
 
void vlc_control_cancel (vlc_cleanup_t *)
 Internal handler for thread cancellation. More...
 
unsigned long vlc_thread_id (void)
 Thread identifier. More...
 
vlc_tick_t vlc_tick_now (void)
 Precision monotonic clock. More...
 
void vlc_tick_wait (vlc_tick_t deadline)
 Waits until a deadline. More...
 
void vlc_tick_sleep (vlc_tick_t delay)
 Waits for an interval of time. More...
 
int vlc_timer_create (vlc_timer_t *id, void(*func)(void *), void *data)
 Initializes an asynchronous timer. More...
 
void vlc_timer_destroy (vlc_timer_t timer)
 Destroys an initialized timer. More...
 
void vlc_timer_schedule (vlc_timer_t timer, bool absolute, vlc_tick_t value, vlc_tick_t interval)
 Arms or disarms an initialized timer. More...
 
static void vlc_timer_disarm (vlc_timer_t timer)
 
static void vlc_timer_schedule_asap (vlc_timer_t timer, vlc_tick_t interval)
 
unsigned vlc_timer_getoverrun (vlc_timer_t timer)
 Fetches and resets the overrun counter for a timer. More...
 
unsigned vlc_GetCPUCount (void)
 Count CPUs. More...
 
void vlc_global_mutex (unsigned, bool)
 Internal handler for global mutexes. More...
 

Detailed Description

Thread primitive declarations.