VLC 4.0.0-dev
|
The condition variable is the most common and generic mean for threads to wait for events triggered by other threads. More...
Data Structures | |
struct | vlc_cond_t |
Condition variable. More... | |
Macros | |
#define | VLC_STATIC_COND { NULL, VLC_STATIC_MUTEX } |
Static initializer for (static) condition variable. More... | |
Functions | |
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) |
The condition variable is the most common and generic mean for threads to wait for events triggered by other threads.
See also POSIX pthread_cond_t
.
#define VLC_STATIC_COND { NULL, VLC_STATIC_MUTEX } |
Static initializer for (static) condition variable.
void vlc_cond_broadcast | ( | vlc_cond_t * | cond | ) |
Wakes up all threads waiting on a condition variable.
References vlc_cond_t::head, vlc_cond_t::lock, vlc_cond_waiter::next, vlc_cond_signal_waiter(), vlc_mutex_lock(), and vlc_mutex_unlock().
Referenced by TriggerCallback(), TriggerListCallback(), vlc_clock_main_ChangePause(), vlc_clock_main_reset(), vlc_clock_master_set_delay(), vlc_clock_master_update(), vlc_clock_slave_set_delay(), vlc_clock_Wake(), vlc_executor_Delete(), vlc_h2_initial_window_update(), vlc_h2_stream_end(), vlc_h2_stream_reset(), vlc_h2_stream_window_update(), vlc_h2_window_update(), vout_snapshot_End(), and vout_snapshot_Set().
void vlc_cond_init | ( | vlc_cond_t * | cond | ) |
Initializes a condition variable.
References vlc_cond_t::head, vlc_cond_t::lock, and vlc_mutex_init().
Referenced by AddressCreate(), CreateDecoder(), dialog_add_locked(), input_Create(), picture_pool_New(), spu_Create(), TaskNew(), TsStart(), var_Create(), vlc_clock_main_New(), vlc_executor_New(), vlc_h2_conn_create(), vlc_h2_output_create(), vlc_h2_stream_open(), vlc_mwait_i11e(), vlc_player_InitLocks(), vlc_queue_Init(), vlc_timer_create(), vlm_New(), vout_control_Init(), and vout_snapshot_New().
void vlc_cond_signal | ( | vlc_cond_t * | cond | ) |
Wakes up one thread waiting on a condition variable.
If any thread is currently waiting on the condition variable, at least one of those threads will be woken up. Otherwise, this function has no effects.
References vlc_cond_t::head, vlc_cond_t::lock, vlc_cond_waiter::next, vlc_cond_waiter::pprev, vlc_cond_signal_waiter(), vlc_mutex_lock(), and vlc_mutex_unlock().
Referenced by addons_manager_Gather(), DecoderThread(), DecoderWaitUnblock(), dialog_id_post(), dialog_wait_interrupted(), finder_thread_interrupted(), input_ControlPush(), input_Stop(), InstallEntry(), installer_thread_interrupted(), Interrupt(), on_thumbnailer_input_event(), picture_pool_ReleaseClone(), player_on_state_changed(), QueuePush(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), spu_Destroy(), spu_PrerenderEnqueue(), spu_PrerenderThread(), spu_PrerenderWake(), ThreadRun(), TsChangePause(), TsPushCmd(), TsStop(), vlc_executor_Cancel(), vlc_h2_output_destroy(), vlc_h2_output_queue(), vlc_h2_stream_data(), vlc_h2_stream_headers(), vlc_h2_stream_wake_up(), vlc_input_decoder_Delete(), vlc_input_decoder_StartWait(), vlc_input_decoder_StopWait(), vlc_mwait_i11e_wake(), vlc_player_CancelWaitError(), vlc_player_Delete(), vlc_player_destructor_AddInput(), vlc_player_destructor_AddStoppingInput(), vlc_queue_Signal(), vlc_timer_destroy(), vlc_timer_schedule(), vlm_Delete(), vout_control_Hold(), vout_control_ReleaseAndWake(), vout_control_ReleaseUnlocked(), vout_control_Wait(), and vout_control_Wake().
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.
This works like vlc_cond_wait() but with an additional time-out. The time-out is expressed as an absolute timestamp using the same arbitrary time reference as the vlc_tick_now() and vlc_tick_wait() functions.
cond | condition variable to wait on |
mutex | mutex which is unlocked while waiting, then locked again when waking up |
deadline | absolute timeout |
References vlc_mutex_t::recursion, vlc_cond_waiter::value, vlc_atomic_timedwait(), vlc_cond_wait_finish(), and vlc_cond_wait_prepare().
Referenced by ControlPop(), RunnableRun(), RunThread(), vlc_clock_Wait(), vlc_mwait_i11e(), vlc_player_WaitRetryDelay(), vlc_timer_thread(), vout_control_Wait(), and vout_snapshot_Get().
int vlc_cond_timedwait_daytime | ( | vlc_cond_t * | cond, |
vlc_mutex_t * | mutex, | ||
time_t | deadline | ||
) |
References vlc_cond_waiter::value, vlc_atomic_timedwait_daytime(), vlc_cond_wait_finish(), and vlc_cond_wait_prepare().
Referenced by Manage().
void vlc_cond_wait | ( | vlc_cond_t * | cond, |
vlc_mutex_t * | mutex | ||
) |
Waits on a condition variable.
The calling thread will be suspended until another thread calls vlc_cond_signal() or vlc_cond_broadcast() on the same condition variable, the thread is cancelled with vlc_cancel(), or the system causes a spurious unsolicited wake-up.
A mutex is needed to wait on a condition variable. It must not be a recursive mutex. Although it is possible to use the same mutex for multiple condition, it is not valid to use different mutexes for the same condition variable at the same time from different threads.
The canonical way to use a condition variable to wait for event foobar is:
cond | condition variable to wait on |
mutex | mutex which is unlocked while waiting, then locked again when waking up. |
References vlc_mutex_t::recursion, vlc_cond_waiter::value, vlc_atomic_wait(), vlc_cond_wait_finish(), and vlc_cond_wait_prepare().
Referenced by ControlPop(), dialog_wait(), FinderThread(), InstallerThread(), Manage(), picture_pool_Wait(), QueueTake(), RunnableRun(), spu_PrerenderCancel(), spu_PrerenderPause(), spu_PrerenderSync(), spu_PrerenderThread(), TsRun(), vlc_executor_WaitIdle(), vlc_fifo_WaitCond(), vlc_h2_output_dequeue(), vlc_h2_stream_read(), vlc_h2_stream_wait(), vlc_h2_stream_write(), vlc_player_CondWait(), vlc_player_destructor_Thread(), vlc_queue_Wait(), vlc_timer_thread(), vout_control_Hold(), vout_control_Wait(), and WaitUnused().