#include <read_write_mutex.hpp>
Use this if reads are quick. This is a drop-in replacement for C++17's std::shared_mutex. This mutex is NOT recursive!
◆ lock()
void emilib::FastReadWriteMutex::lock |
( |
| ) |
|
|
inline |
Locks the mutex for exclusive access (e.g. for a write operation). If another thread has already locked the mutex, a call to lock will block execution until the lock is acquired. This will be done using a spin-lock. If this is wasting too much CPU, consider using SlowReadWriteMutex instead. If lock is called by a thread that already owns the mutex in any mode (shared or exclusive), the behavior is undefined.
◆ lock_shared()
void emilib::FastReadWriteMutex::lock_shared |
( |
| ) |
|
|
inline |
Acquires shared ownership of the mutex (e.g. for a read operation). If another thread is holding the mutex in exclusive ownership, a call to lock_shared will block execution until shared ownership can be acquired.
◆ try_lock()
bool emilib::FastReadWriteMutex::try_lock |
( |
| ) |
|
|
inline |
Tries to lock the mutex. Returns immediately. On successful lock acquisition returns true, otherwise returns false. This function is allowed to fail spuriously and return false even if the mutex is not currently locked by any other thread. If try_lock is called by a thread that already owns the mutex, the behavior is undefined.
◆ try_lock_shared()
bool emilib::FastReadWriteMutex::try_lock_shared |
( |
| ) |
|
|
inline |
Tries to lock the mutex in shared mode. Returns immediately. On successful lock acquisition returns true, otherwise returns false. This function is allowed to fail spuriously and return false even if the mutex is not currenly exclusively locked by any other thread.
◆ unlock()
void emilib::FastReadWriteMutex::unlock |
( |
| ) |
|
|
inline |
Unlocks the mutex. The mutex must be locked by the current thread of execution, otherwise, the behavior is undefined.
◆ unlock_shared()
void emilib::FastReadWriteMutex::unlock_shared |
( |
| ) |
|
|
inline |
Releases the mutex from shared ownership by the calling thread. The mutex must be locked by the current thread of execution in shared mode, otherwise, the behavior is undefined.
The documentation for this class was generated from the following file: