VLC  4.0.0-dev
Typedefs | Functions
Collaboration diagram for Thread-specific variables:

Typedefs

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

Functions

VLC_EXPORT int vlc_threadvar_create (vlc_threadvar_t *key, void(*destr)(void *))
 Allocates a thread-specific variable. More...
 
VLC_EXPORT void vlc_threadvar_delete (vlc_threadvar_t *)
 Deallocates a thread-specific variable. More...
 
VLC_EXPORT int vlc_threadvar_set (vlc_threadvar_t key, void *value)
 Sets a thread-specific variable. More...
 
VLC_EXPORT 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()

VLC_EXPORT 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_mutex, unlikely, var, vlc_mutex_lock(), vlc_mutex_unlock(), and vlc_threadvar_last.

Referenced by _DLL_InitTerm().

◆ vlc_threadvar_delete()

VLC_EXPORT void vlc_threadvar_delete ( vlc_threadvar_t )

Deallocates a thread-specific variable.

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

Referenced by _DLL_InitTerm().

◆ vlc_threadvar_get()

VLC_EXPORT void* vlc_threadvar_get ( vlc_threadvar_t  )

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_cancel_addr_clear(), vlc_cancel_addr_set(), vlc_control_cancel(), vlc_DosWaitEventSemEx(), vlc_restorecancel(), vlc_savecancel(), vlc_select(), vlc_testcancel(), vlc_thread_cleanup(), and vlc_threadvars_cleanup().

◆ vlc_threadvar_set()

VLC_EXPORT 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_entry(), vlc_thread_cleanup(), and vlc_threadvars_cleanup().