VLC 4.0.0-dev
Loading...
Searching...
No Matches

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_once_t
 One-time initialization. More...
 

Macros

#define LIBVLC_USE_PTHREAD   1
 Whether LibVLC threads are based on POSIX threads.
 
#define LIBVLC_USE_PTHREAD_CLEANUP   1
 Whether LibVLC thread cancellation is based on POSIX threads.
 
#define VLC_THREAD_CANCELED   PTHREAD_CANCELED
 Return value of a canceled thread.
 
#define VLC_STATIC_MUTEX
 Static initializer for (static) mutex.
 
#define vlc_mutex_assert(m)   assert(vlc_mutex_held(m))
 Asserts that a mutex is locked by the calling thread.
 
#define VLC_STATIC_COND   { NULL, VLC_STATIC_MUTEX }
 Static initializer for (static) condition variable.
 
#define VLC_STATIC_ONCE   { 0 }
 Static initializer for one-time initialization.
 
#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.
 
#define vlc_cleanup_pop()   pthread_cleanup_pop (0)
 Unregisters the last cancellation handler.
 
#define vlc_global_lock(n)   vlc_global_mutex(n, true)
 Acquires a global mutex.
 
#define vlc_global_unlock(n)   vlc_global_mutex(n, false)
 Releases a global mutex.
 

Typedefs

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

Detailed Description

Thread primitive declarations.