VCV Rack API v2
Loading...
Searching...
No Matches
rack::SharedMutex Struct Reference

Allows multiple "reader" threads to obtain a lock simultaneously, but only one "writer" thread. More...

#include <mutex.hpp>

Public Member Functions

 SharedMutex ()
 
 ~SharedMutex ()
 
void lock ()
 
bool try_lock ()
 Returns whether the lock was acquired.
 
void unlock ()
 
void lock_shared ()
 
bool try_lock_shared ()
 Returns whether the lock was acquired.
 
void unlock_shared ()
 

Public Attributes

pthread_rwlock_t rwlock
 

Detailed Description

Allows multiple "reader" threads to obtain a lock simultaneously, but only one "writer" thread.

This implementation is currently just a wrapper for pthreads, which works on Linux/Mac/. This is available in C++17 as std::shared_mutex, but unfortunately we're using C++11.

Locking should be avoided in real-time audio threads.

Constructor & Destructor Documentation

◆ SharedMutex()

rack::SharedMutex::SharedMutex ( )
inline

◆ ~SharedMutex()

rack::SharedMutex::~SharedMutex ( )
inline

Member Function Documentation

◆ lock()

void rack::SharedMutex::lock ( )
inline

◆ try_lock()

bool rack::SharedMutex::try_lock ( )
inline

Returns whether the lock was acquired.

◆ unlock()

void rack::SharedMutex::unlock ( )
inline

◆ lock_shared()

void rack::SharedMutex::lock_shared ( )
inline

◆ try_lock_shared()

bool rack::SharedMutex::try_lock_shared ( )
inline

Returns whether the lock was acquired.

◆ unlock_shared()

void rack::SharedMutex::unlock_shared ( )
inline

Member Data Documentation

◆ rwlock

pthread_rwlock_t rack::SharedMutex::rwlock

The documentation for this struct was generated from the following file: