VLC 4.0.0-dev
Collaboration diagram for Thread-specific variables:

Typedefs

typedef pthread_key_t vlc_threadvar_t
 Thread-local key handle. More...
 

Functions

int vlc_threadvar_create (vlc_threadvar_t *key, void(*destr)(void *))
 Allocates a thread-specific variable. More...
 
void vlc_threadvar_delete (vlc_threadvar_t *)
 Deallocates a thread-specific variable. More...
 
int vlc_threadvar_set (vlc_threadvar_t key, void *value)
 Sets a thread-specific variable. More...
 
void * vlc_threadvar_get (vlc_threadvar_t)
 Gets the value of a thread-local variable for the calling thread. More...
 

Detailed Description

Typedef Documentation

◆ vlc_threadvar_t

typedef pthread_key_t vlc_threadvar_t

Thread-local key handle.

Function Documentation

◆ vlc_threadvar_create()

int vlc_threadvar_create ( vlc_threadvar_t key,
void(*)(void *)  destr 
)

Allocates a thread-specific variable.

Parameters
keywhere to store the thread-specific variable handle
destra destruction callback. It is called whenever a thread exits and the thread-specific variable has a non-NULL value.
Returns
0 on success, a system error code otherwise. This function can actually fail: on most systems, there is a fixed limit to the number of thread-specific variables in a given process.

References super_lock, super_mutex, unlikely, var, vlc_mutex_lock(), vlc_mutex_unlock(), and vlc_threadvar_last.

◆ vlc_threadvar_delete()

void vlc_threadvar_delete ( vlc_threadvar_t p_tls)

Deallocates a thread-specific variable.

References super_lock, super_mutex, var, vlc_mutex_lock(), vlc_mutex_unlock(), and vlc_threadvar_last.

◆ vlc_threadvar_get()

void * vlc_threadvar_get ( vlc_threadvar_t  key)

Gets the value of a thread-local variable for the calling thread.

This function cannot fail.

Returns
the value associated with the given variable for the calling or NULL if no value was set.

Referenced by vlc_thread_cleanup().

◆ vlc_threadvar_set()

int vlc_threadvar_set ( vlc_threadvar_t  key,
void *  value 
)

Sets a thread-specific variable.

Parameters
keythread-local variable key (created with vlc_threadvar_create())
valuenew value for the variable for the calling thread
Returns
0 on success, a system error code otherwise.

Referenced by vlc_thread_cleanup().