VLC  4.0.0-dev
Macros | Typedefs | Functions

Read/write locks are a type of thread synchronization primitive meant to protect access to data that is mostly read, and rarely written. More...

Collaboration diagram for Read/write locks:

Macros

#define VLC_STATIC_RWLOCK   PTHREAD_RWLOCK_INITIALIZER
 Static initializer for (static) read/write lock. More...
 

Typedefs

typedef pthread_rwlock_t vlc_rwlock_t
 Read/write lock. More...
 

Functions

void vlc_rwlock_init (vlc_rwlock_t *)
 Initializes a read/write lock. More...
 
void vlc_rwlock_destroy (vlc_rwlock_t *)
 Destroys an initialized unused read/write lock. More...
 
void vlc_rwlock_rdlock (vlc_rwlock_t *)
 Acquires a read/write lock for reading. More...
 
void vlc_rwlock_wrlock (vlc_rwlock_t *)
 Acquires a read/write lock for writing. More...
 
void vlc_rwlock_unlock (vlc_rwlock_t *)
 Releases a read/write lock. More...
 

Detailed Description

Read/write locks are a type of thread synchronization primitive meant to protect access to data that is mostly read, and rarely written.

As long as no threads tries to acquire the lock for "writing", any number of threads can acquire the lock for "reading".

See also POSIX pthread_rwlock_t .

Macro Definition Documentation

◆ VLC_STATIC_RWLOCK

#define VLC_STATIC_RWLOCK   PTHREAD_RWLOCK_INITIALIZER

Static initializer for (static) read/write lock.

Typedef Documentation

◆ vlc_rwlock_t

typedef pthread_rwlock_t vlc_rwlock_t

Read/write lock.

Storage space for a slim reader/writer lock.

Function Documentation

◆ vlc_rwlock_destroy()

void vlc_rwlock_destroy ( vlc_rwlock_t )

Destroys an initialized unused read/write lock.

References VLC_THREAD_ASSERT.

Referenced by _DLL_InitTerm(), DllMain(), vlc_cond_timedwait_daytime(), and vlc_LogSwitchClose().

◆ vlc_rwlock_init()

void vlc_rwlock_init ( vlc_rwlock_t )

Initializes a read/write lock.

After use, a read/write lock must be deinitialized with vlc_rwlock_destroy().

References unlikely.

Referenced by _DLL_InitTerm(), DllMain(), vlc_cond_timedwait_daytime(), and vlc_LogSwitchCreate().

◆ vlc_rwlock_rdlock()

void vlc_rwlock_rdlock ( vlc_rwlock_t )

Acquires a read/write lock for reading.

Note
Recursion is allowed.
This function may be a point of cancellation.

References VLC_THREAD_ASSERT.

Referenced by config_AutoSaveConfigFile(), config_GetFloat(), config_GetInt(), config_GetPsz(), config_SaveConfigFile(), vlc_cond_timedwait_daytime(), and vlc_vaLogSwitch().

◆ vlc_rwlock_unlock()

void vlc_rwlock_unlock ( vlc_rwlock_t )

Releases a read/write lock.

The calling thread must hold the lock. Otherwise behaviour is undefined.

Note
This function is not a cancellation point.

References VLC_THREAD_ASSERT.

Referenced by config_AutoSaveConfigFile(), config_GetFloat(), config_GetInt(), config_GetPsz(), config_LoadConfigFile(), config_PutFloat(), config_PutInt(), config_PutPsz(), config_ResetAll(), config_SaveConfigFile(), vlc_cond_timedwait_daytime(), vlc_LogSwitch(), and vlc_vaLogSwitch().

◆ vlc_rwlock_wrlock()

void vlc_rwlock_wrlock ( vlc_rwlock_t )

Acquires a read/write lock for writing.

Recursion is not allowed.

Note
This function may be a point of cancellation.

References VLC_THREAD_ASSERT.

Referenced by config_LoadConfigFile(), config_PutFloat(), config_PutInt(), config_PutPsz(), config_ResetAll(), vlc_cond_timedwait_daytime(), and vlc_LogSwitch().