VLC  4.0.0-dev
Data Structures | 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. As long as no threads tries to acquire the lock for "writing", any number of threads can acquire the lock for "reading". More...

Collaboration diagram for Read/write locks:

Data Structures

struct  vlc_rwlock
 Read/write lock. More...
 

Macros

#define VLC_STATIC_RWLOCK   { VLC_STATIC_MUTEX, VLC_STATIC_COND, 0 }
 Static initializer for (static) read/write lock. More...
 

Typedefs

typedef struct vlc_rwlock vlc_rwlock_t
 Read/write lock. More...
 

Functions

VLC_EXPORT void vlc_rwlock_init (vlc_rwlock_t *)
 Initializes a read/write lock. More...
 
VLC_EXPORT void vlc_rwlock_rdlock (vlc_rwlock_t *)
 Acquires a read/write lock for reading. More...
 
VLC_EXPORT void vlc_rwlock_wrlock (vlc_rwlock_t *)
 Acquires a read/write lock for writing. More...
 
VLC_EXPORT 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   { VLC_STATIC_MUTEX, VLC_STATIC_COND, 0 }

Static initializer for (static) read/write lock.

Typedef Documentation

◆ vlc_rwlock_t

typedef struct vlc_rwlock vlc_rwlock_t

Read/write lock.

Storage space for a slim reader/writer lock.

Function Documentation

◆ vlc_rwlock_init()

VLC_EXPORT void vlc_rwlock_init ( vlc_rwlock_t )

Initializes a read/write lock.

References lock, vlc_cond_init(), and vlc_mutex_init().

Referenced by vlc_LogSwitchCreate().

◆ vlc_rwlock_rdlock()

VLC_EXPORT void vlc_rwlock_rdlock ( vlc_rwlock_t )

◆ vlc_rwlock_unlock()

VLC_EXPORT 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 lock, vlc_cond_broadcast(), vlc_cond_signal(), vlc_mutex_lock(), vlc_mutex_unlock(), and WRITER_BIT.

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

◆ vlc_rwlock_wrlock()

VLC_EXPORT void vlc_rwlock_wrlock ( vlc_rwlock_t )

Acquires a read/write lock for writing.

Recursion is not allowed.

References lock, vlc_cond_wait(), vlc_mutex_lock(), vlc_mutex_unlock(), and WRITER_BIT.

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