VLC 4.0.0-dev
|
Low-level queue functions. More...
Functions | |
static void | vlc_queue_Lock (vlc_queue_t *q) |
Locks a queue. More... | |
static void | vlc_queue_Unlock (vlc_queue_t *q) |
Unlocks a queue. More... | |
static void | vlc_queue_Signal (vlc_queue_t *q) |
Wakes one thread waiting for a queue entry up. More... | |
static void | vlc_queue_Wait (vlc_queue_t *q) |
Waits for a queue entry. More... | |
void | vlc_queue_EnqueueUnlocked (vlc_queue_t *, void *entry) |
Queues an entry (without locking). More... | |
void * | vlc_queue_DequeueUnlocked (vlc_queue_t *) |
Dequeues the oldest entry (without locking). More... | |
void * | vlc_queue_DequeueAllUnlocked (vlc_queue_t *) |
Dequeues all entries (without locking). More... | |
static bool | vlc_queue_IsEmpty (const vlc_queue_t *q) |
Checks if a queue is empty (without locking). More... | |
Low-level queue functions.
In some cases, the high-level queue functions do not exactly fit the use case requirements, and it is necessary to access the queue internals. This typically occurs when threads wait for elements to be added to the queue at the same time as some other type of events.
void * vlc_queue_DequeueAllUnlocked | ( | vlc_queue_t * | q | ) |
Dequeues all entries (without locking).
This is equivalent to calling vlc_queue_DequeueUnlocked() repeatedly until the queue is emptied. However this function is much faster than that, as it does not need to update the linked-list pointers.
References vlc_queue::first, vlc_queue::lastp, vlc_queue::lock, and vlc_mutex_assert.
Referenced by vlc_fifo_DequeueAllUnlocked(), vlc_queue_DequeueAll(), and vlc_stream_fifo_Destroy().
void * vlc_queue_DequeueUnlocked | ( | vlc_queue_t * | q | ) |
Dequeues the oldest entry (without locking).
This function dequeues an entry from a thread-safe queue. It is assumed that the caller already holds the queue lock; otherwise the behaviour is undefined.
References vlc_queue::first, vlc_queue::lastp, vlc_queue::lock, next_get(), vlc_queue::next_offset, next_set(), and vlc_mutex_assert.
Referenced by vlc_fifo_DequeueUnlocked(), vlc_queue_Dequeue(), and vlc_queue_DequeueKillable().
void vlc_queue_EnqueueUnlocked | ( | vlc_queue_t * | q, |
void * | entry | ||
) |
Queues an entry (without locking).
This function enqueues an entry, or rather a linked-list of entries, in a thread-safe queue, without taking the queue lock.
entry | NULL-terminated list of entries to queue (if NULL, this function has no effects) |
References entry_get(), entry_set(), vlc_queue::lastp, vlc_queue::lock, next_get(), vlc_queue::next_offset, next_p(), vlc_mutex_assert, and vlc_queue_Signal().
Referenced by vlc_fifo_QueueUnlocked(), vlc_queue_Enqueue(), and vlc_stream_fifo_Queue().
|
inlinestatic |
Checks if a queue is empty (without locking).
false | the queue contains one or more entries |
true | the queue is empty |
References vlc_queue::first.
Referenced by vlc_fifo_IsEmpty(), vlc_queue_Dequeue(), and vlc_queue_DequeueKillable().
|
inlinestatic |
Locks a queue.
No more than one thread can lock a queue at any given time, and no other thread can modify the queue while it is locked. Accordingly, if the queue is already locked by another thread, this function waits.
Use vlc_queue_Unlock() to release the lock.
References vlc_queue::lock, and vlc_mutex_lock().
Referenced by vlc_fifo_Lock(), vlc_queue_Dequeue(), vlc_queue_DequeueAll(), vlc_queue_DequeueKillable(), vlc_queue_Enqueue(), vlc_queue_Kill(), vlc_stream_fifo_Close(), vlc_stream_fifo_Destroy(), and vlc_stream_fifo_Queue().
|
inlinestatic |
Wakes one thread waiting for a queue entry up.
References vlc_cond_signal(), and vlc_queue::wait.
Referenced by vlc_fifo_Signal(), vlc_queue_EnqueueUnlocked(), vlc_queue_Kill(), and vlc_stream_fifo_Close().
|
inlinestatic |
Unlocks a queue.
This releases the lock on a queue, allowing other threads to manipulate the queue. The behaviour is undefined if the calling thread is not holding the queue lock.
References vlc_queue::lock, and vlc_mutex_unlock().
Referenced by vlc_fifo_Unlock(), vlc_queue_Dequeue(), vlc_queue_DequeueAll(), vlc_queue_DequeueKillable(), vlc_queue_Enqueue(), vlc_queue_Kill(), vlc_stream_fifo_Close(), vlc_stream_fifo_Destroy(), and vlc_stream_fifo_Queue().
|
inlinestatic |
Waits for a queue entry.
References vlc_queue::lock, vlc_cond_wait(), and vlc_queue::wait.
Referenced by vlc_fifo_Wait(), vlc_queue_Dequeue(), and vlc_queue_DequeueKillable().