VLC 4.0.0-dev
|
Atomic operations do not require locking, but they are not very powerful. More...
Go to the source code of this file.
Data Structures | |
struct | vlc_atomic_rc_t |
Macros | |
#define | VLC_STATIC_RC |
Typedefs | |
typedef struct vlc_atomic_rc_t | vlc_atomic_rc_t |
Functions | |
static void | vlc_atomic_rc_init (vlc_atomic_rc_t *rc) |
Init the RC to 1. More... | |
static void | vlc_atomic_rc_inc (vlc_atomic_rc_t *rc) |
Increment the RC. More... | |
static bool | vlc_atomic_rc_dec (vlc_atomic_rc_t *rc) |
Decrement the RC and return true if it reaches 0. More... | |
static uintptr_t | vlc_atomic_rc_get (const vlc_atomic_rc_t *rc) |
Returns the current reference count. More... | |
void | vlc_atomic_wait (void *addr, unsigned val) |
Waits on an address. More... | |
int | vlc_atomic_timedwait (void *addr, unsigned val, vlc_tick_t deadline) |
Waits on an address with a time-out. More... | |
int | vlc_atomic_timedwait_daytime (void *addr, unsigned val, time_t deadline) |
void | vlc_atomic_notify_one (void *addr) |
Wakes up one thread on an address. More... | |
void | vlc_atomic_notify_all (void *addr) |
Wakes up all thread on an address. More... | |
Atomic operations do not require locking, but they are not very powerful.
#define VLC_STATIC_RC |
typedef struct vlc_atomic_rc_t vlc_atomic_rc_t |
void vlc_atomic_notify_all | ( | void * | addr | ) |
Wakes up all thread on an address.
Wakes up all threads sleeping on the specified address (if any). Any thread sleeping within a call to vlc_atomic_wait() or vlc_atomic_timedwait() with the specified address as first call parameter will be woken up.
addr | address identifying which threads to wake up |
References wait_bucket::lock, vlc_futex_wake(), vlc_umtx_wake(), wait_bucket::wait, wait_bucket_get(), and wait_bucket::waiters.
Referenced by vlc_atomic_notify_one(), vlc_latch_count_down_ready(), vlc_once_complete(), and vlc_queuedmutex_unlock().
void vlc_atomic_notify_one | ( | void * | addr | ) |
Wakes up one thread on an address.
Wakes up (at least) one of the thread sleeping on the specified address. The address must be equal to the first parameter given by at least one thread sleeping within the vlc_atomic_wait() or vlc_atomic_timedwait() functions. If no threads are found, this function does nothing.
addr | address identifying which threads may be woken up |
References vlc_atomic_notify_all(), vlc_futex_wake(), and vlc_umtx_wake().
Referenced by vlc_cancel(), vlc_cond_signal_waiter(), vlc_mutex_unlock(), vlc_rcu_read_unlock(), and vlc_sem_post().
|
inlinestatic |
Decrement the RC and return true if it reaches 0.
References vlc_atomic_rc_t::refs, and vlc_assert.
Referenced by addon_entry_Release(), aout_Release(), EsRelease(), input_item_Release(), input_resource_Release(), input_source_Release(), picture_pool_Destroy(), picture_Release(), TaskRelease(), vlc_ancillary_Release(), vlc_decoder_device_Release(), vlc_input_attachment_Release(), vlc_media_source_Release(), vlc_media_tree_Release(), vlc_player_title_list_Release(), vlc_playlist_item_Release(), vlc_renderer_item_release(), vlc_thumbnailer_DestroyRequest(), vlc_video_context_Release(), and vout_Release().
|
inlinestatic |
Returns the current reference count.
This is not safe to use for logic and must only be used for debugging or assertion purposes
References vlc_atomic_rc_t::refs.
Referenced by picture_Destroy(), picture_pool_Get(), and picture_pool_Wait().
|
inlinestatic |
Increment the RC.
References vlc_atomic_rc_t::refs, vlc_assert, and VLC_UNUSED.
Referenced by addon_entry_Hold(), aout_Hold(), EsHold(), input_item_Hold(), input_resource_Hold(), input_source_Hold(), picture_Hold(), picture_pool_ClonePicture(), RequestCommon(), vlc_ancillary_Hold(), vlc_decoder_device_Hold(), vlc_input_attachment_Hold(), vlc_media_source_Hold(), vlc_media_tree_Hold(), vlc_player_title_list_Hold(), vlc_playlist_item_Hold(), vlc_renderer_item_hold(), vlc_video_context_Hold(), and vout_Hold().
|
inlinestatic |
Init the RC to 1.
References vlc_atomic_rc_t::refs.
Referenced by addon_entry_New(), aout_New(), EsOutAddLocked(), input_item_NewExt(), input_resource_New(), InputSourceNew(), picture_InitPrivate(), picture_pool_New(), TaskNew(), vlc_ancillary_CreateWithFreeCb(), vlc_decoder_device_Create(), vlc_input_attachment_New(), vlc_media_source_New(), vlc_media_tree_New(), vlc_player_title_list_Create(), vlc_playlist_item_New(), vlc_renderer_item_new(), vlc_video_context_Create(), and vout_CreateCommon().
int vlc_atomic_timedwait | ( | void * | addr, |
unsigned | val, | ||
vlc_tick_t | deadline | ||
) |
Waits on an address with a time-out.
This function operates as vlc_atomic_wait() but provides an additional time-out. If the deadline is reached, the thread resumes and the function returns.
addr | address to check for |
val | value to match at the address |
deadline | deadline to wait until |
0 | the function was woken up before the time-out |
ETIMEDOUT | the deadline was reached |
References count, wait_bucket::lock, MS_FROM_VLC_TICK, unlikely, vlc_assert_unreachable, vlc_atomic_timedwait_timespec(), vlc_cleanup_pop, vlc_cleanup_push, vlc_futex_wait(), vlc_testcancel(), VLC_TICK_FROM_MS, vlc_tick_now(), vlc_tick_to_timespec(), vlc_timespec_adjust(), vlc_umtx_wait(), vlc_WaitForSingleObject(), wait_bucket::wait, wait_bucket_enter(), and wait_bucket_leave().
Referenced by vlc_cond_timedwait(), vlc_sem_timedwait(), and vlc_tick_wait().
int vlc_atomic_timedwait_daytime | ( | void * | addr, |
unsigned | val, | ||
time_t | deadline | ||
) |
References count, wait_bucket::lock, timespec::tv_sec, unlikely, vlc_assert_unreachable, vlc_atomic_timedwait_timespec(), vlc_cleanup_pop, vlc_cleanup_push, vlc_futex_wait(), vlc_testcancel(), vlc_timespec_adjust(), vlc_WaitForSingleObject(), wait_bucket::wait, wait_bucket_enter(), and wait_bucket_leave().
Referenced by vlc_cond_timedwait_daytime().
void vlc_atomic_wait | ( | void * | addr, |
unsigned | val | ||
) |
Waits on an address.
Puts the calling thread to sleep if a specific unsigned 32-bits value is stored at a specified address. The thread will sleep until it is woken up by a call to vlc_atomic_notify_one() or vlc_atomic_notify_all() in another thread, or spuriously.
If the value does not match, do nothing and return immediately.
addr | address to check for |
val | value to match at the address |
References count, wait_bucket::lock, vlc_cleanup_pop, vlc_cleanup_push, vlc_futex_wait(), vlc_testcancel(), vlc_umtx_wait(), vlc_WaitForSingleObject(), wait_bucket::wait, wait_bucket_enter(), and wait_bucket_leave().
Referenced by vlc_cond_wait(), vlc_latch_wait(), vlc_mutex_lock(), vlc_once_begin(), vlc_queuedmutex_lock(), vlc_rcu_synchronize(), and vlc_sem_wait().