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

Macros

#define FUTEX_WAKE_PRIVATE   FUTEX_WAKE
 
#define FUTEX_WAIT_PRIVATE   FUTEX_WAIT
 
#define FUTEX_WAIT_BITSET_PRIVATE   FUTEX_WAIT_BITSET
 

Functions

unsigned long vlc_thread_id (void)
 Thread identifier. More...
 
void() vlc_thread_set_name (const char *name)
 Set the thread name of the current thread. More...
 
static int sys_futex (void *addr, int op, unsigned val, const struct timespec *to, void *addr2, int val3)
 
static int vlc_futex_wake (void *addr, int nr)
 
static int vlc_futex_wait (void *addr, unsigned flags, unsigned val, const struct timespec *to)
 
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...
 
int vlc_atomic_timedwait_daytime (void *addr, unsigned val, time_t deadline)
 

Macro Definition Documentation

◆ FUTEX_WAIT_BITSET_PRIVATE

#define FUTEX_WAIT_BITSET_PRIVATE   FUTEX_WAIT_BITSET

◆ FUTEX_WAIT_PRIVATE

#define FUTEX_WAIT_PRIVATE   FUTEX_WAIT

◆ FUTEX_WAKE_PRIVATE

#define FUTEX_WAKE_PRIVATE   FUTEX_WAKE

Function Documentation

◆ sys_futex()

static int sys_futex ( void *  addr,
int  op,
unsigned  val,
const struct timespec to,
void *  addr2,
int  val3 
)
static

Referenced by vlc_futex_wait(), and vlc_futex_wake().

◆ 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_futex_wake().

◆ 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_futex_wake().

◆ 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 vlc_assert_unreachable, vlc_futex_wait(), and vlc_tick_to_timespec().

◆ vlc_atomic_timedwait_daytime()

int vlc_atomic_timedwait_daytime ( void *  addr,
unsigned  val,
time_t  deadline 
)

◆ 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_futex_wait().

◆ vlc_futex_wait()

static int vlc_futex_wait ( void *  addr,
unsigned  flags,
unsigned  val,
const struct timespec to 
)
static

◆ vlc_futex_wake()

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