VLC  4.0.0-dev
Functions
thread.c File Reference
Include dependency graph for thread.c:

Functions

unsigned long vlc_thread_id (void)
 Thread identifier. More...
 
static int vlc_umtx_wake (void *addr, int nr)
 
static int vlc_umtx_wait (void *addr, unsigned val, const struct timespec *ts)
 
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...
 
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...
 

Function Documentation

◆ vlc_atomic_notify_all()

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.

Parameters
addraddress identifying which threads to wake up

References vlc_umtx_wake().

Referenced by vlc_atomic_notify_one(), and vlc_once().

◆ vlc_atomic_notify_one()

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.

Parameters
addraddress identifying which threads may be woken up

References vlc_umtx_wake().

Referenced by vlc_cancel(), vlc_cond_signal_waiter(), vlc_mutex_unlock(), and vlc_sem_post().

◆ vlc_atomic_timedwait()

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.

Parameters
addraddress to check for
valvalue to match at the address
deadlinedeadline to wait until
Return values
0the function was woken up before the time-out
ETIMEDOUTthe deadline was reached

References timespec_from_vlc_tick(), and vlc_umtx_wait().

Referenced by vlc_cond_timedwait(), vlc_sem_timedwait(), and vlc_tick_wait().

◆ vlc_atomic_wait()

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.

Parameters
addraddress to check for
valvalue to match at the address

References vlc_umtx_wait().

Referenced by vlc_cond_wait(), vlc_mutex_lock(), vlc_once(), and vlc_sem_wait().

◆ vlc_umtx_wait()

static int vlc_umtx_wait ( void *  addr,
unsigned  val,
const struct timespec ts 
)
static

◆ vlc_umtx_wake()

static int vlc_umtx_wake ( void *  addr,
int  nr 
)
static