VLC
4.0.0-dev
|
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...
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... | |
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
.
#define VLC_STATIC_RWLOCK { VLC_STATIC_MUTEX, VLC_STATIC_COND, 0 } |
Static initializer for (static) read/write lock.
typedef struct vlc_rwlock vlc_rwlock_t |
Read/write lock.
Storage space for a slim reader/writer lock.
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_EXPORT void vlc_rwlock_rdlock | ( | vlc_rwlock_t * | ) |
Acquires a read/write lock for reading.
References lock, READER_MASK, unlikely, vlc_cond_wait(), vlc_mutex_lock(), vlc_mutex_unlock(), and WRITER_BIT.
Referenced by config_AutoSaveConfigFile(), config_GetFloat(), config_GetInt(), config_GetPsz(), config_SaveConfigFile(), and vlc_vaLogSwitch().
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.
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_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().