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. 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

void vlc_rwlock_init (vlc_rwlock_t *)
 Initializes a 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   { 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()

void vlc_rwlock_init ( vlc_rwlock_t lock)

Initializes a read/write lock.

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

Referenced by vlc_LogSwitchCreate().

◆ vlc_rwlock_rdlock()

void vlc_rwlock_rdlock ( vlc_rwlock_t lock)

Acquires a read/write lock for reading.

Note
Recursion is allowed.

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

Referenced by config_GetPsz(), config_SaveConfigFile(), and vlc_vaLogSwitch().

◆ vlc_rwlock_unlock()

void vlc_rwlock_unlock ( vlc_rwlock_t lock)

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_GetPsz(), config_LoadConfigFile(), config_PutFloat(), config_PutInt(), config_PutPsz(), config_ResetAll(), config_SaveConfigFile(), vlc_LogSwitch(), and vlc_vaLogSwitch().

◆ vlc_rwlock_wrlock()

void vlc_rwlock_wrlock ( vlc_rwlock_t lock)

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