VLC 4.0.0-dev
|
The semaphore is the simplest thread synchronization primitive, consisting of a simple counter. More...
Data Structures | |
struct | vlc_sem_t |
Semaphore. More... | |
Functions | |
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... | |
The semaphore is the simplest thread synchronization primitive, consisting of a simple counter.
See also POSIX sem_t
.
void vlc_sem_init | ( | vlc_sem_t * | sem, |
unsigned | count | ||
) |
Initializes a semaphore.
count | initial semaphore value (typically 0) |
References vlc_sem_t::value, and vlc_cond_waiter::value.
Referenced by TaskNew(), TsStart(), vlc_getaddrinfo_i11e(), and vlc_mta_acquire().
int vlc_sem_post | ( | vlc_sem_t * | sem | ) |
Increments the value of a semaphore.
References unlikely, vlc_sem_t::value, and vlc_atomic_notify_one().
Referenced by Interrupt(), MtaMainLoop(), OnParserEnded(), TsStop(), vlc_gai_thread(), vlc_getaddrinfo_notify(), vlc_interrupt_sem(), and vlc_mta_release().
int vlc_sem_timedwait | ( | vlc_sem_t * | sem, |
vlc_tick_t | deadline | ||
) |
Waits on a semaphore within a deadline.
This function waits for the semaphore just like vlc_sem_wait(), but only up to a given deadline.
sem | semaphore to wait for |
deadline | deadline to wait until |
0 | the semaphore was decremented |
ETIMEDOUT | the deadline was reached |
References likely, vlc_sem_t::value, and vlc_atomic_timedwait().
int vlc_sem_trywait | ( | vlc_sem_t * | sem | ) |
Tries to decrement a semaphore.
This function decrements the semaphore if its value is not zero.
sem | semaphore to decrement |
0 | the semaphore was decremented |
EAGAIN | the semaphore was zero and could not be decremented |
References vlc_sem_t::value.
Referenced by TsRun().
void vlc_sem_wait | ( | vlc_sem_t * | sem | ) |
Waits on a semaphore.
This function atomically waits for the semaphore to become non-zero then decrements it, and returns. If the semaphore is non-zero on entry, it is immediately decremented.
References likely, vlc_sem_t::value, and vlc_atomic_wait().
Referenced by MtaMainLoop(), Parse(), vlc_getaddrinfo_i11e(), vlc_mta_acquire(), and vlc_sem_wait_i11e().