A readers-writer lock class that is able to be suspended.
More...
#include <xsens_mutex.h>
A readers-writer lock class that is able to be suspended.
Definition at line 1344 of file xsens_mutex.h.
◆ LockSuspendable() [1/4]
◆ LockSuspendable() [2/4]
◆ LockSuspendable() [3/4]
Constructs a lock using a suspendable readers-writer mutex.
Definition at line 1361 of file xsens_mutex.h.
◆ LockSuspendable() [4/4]
Constructs a lock using a guarded mutex.
Definition at line 1373 of file xsens_mutex.h.
◆ ~LockSuspendable()
xsens::LockSuspendable::~LockSuspendable |
( |
| ) |
|
|
inline |
◆ isLocked()
bool xsens::LockSuspendable::isLocked |
( |
LockState |
minimumState | ) |
const |
|
inline |
- Returns
- True if the lock has at least the given state. A suspended write lock is treated as a read lock.
- Parameters
-
minimumState | The minimum lock state to check with |
Definition at line 1534 of file xsens_mutex.h.
◆ isSuspended()
bool xsens::LockSuspendable::isSuspended |
( |
| ) |
const |
|
inline |
◆ isUsing() [1/2]
bool xsens::LockSuspendable::isUsing |
( |
GuardedMutex const * |
mutex | ) |
const |
|
inline |
Check if the lock is using the supplied mutex.
- Parameters
-
mutex | The supplied guarded mutex |
- Returns
- True if it is equal
Definition at line 1560 of file xsens_mutex.h.
◆ isUsing() [2/2]
Check if the lock is using the supplied mutex.
- Parameters
-
mutex | The supplied suspendable readers-writer mutex |
- Returns
- True if it is equal
Definition at line 1551 of file xsens_mutex.h.
◆ lock() [1/2]
bool xsens::LockSuspendable::lock |
( |
bool |
write | ) |
|
|
inline |
Convenience function that accepts the boolean write value, forwards to lock(LockState)
- Parameters
-
write | If set to true, write mode is used, otherwise read mode |
- Returns
- True if successfully locked
Definition at line 1442 of file xsens_mutex.h.
◆ lock() [2/2]
bool xsens::LockSuspendable::lock |
( |
LockState |
desiredLockState | ) |
|
|
inline |
Make sure that the lock has exactly the given lock state.
The lock will be upgraded/downgraded as required, possibly unlocking in between
- Parameters
-
desiredLockState | If set not to read lock state then it will lock the mutex |
- Returns
- True if successfully locked
Definition at line 1393 of file xsens_mutex.h.
◆ lockRead()
bool xsens::LockSuspendable::lockRead |
( |
| ) |
|
|
inline |
Convenience function for lock(LS_Read);.
- Returns
- True if successful
Definition at line 1450 of file xsens_mutex.h.
◆ lockSuspendedWrite()
bool xsens::LockSuspendable::lockSuspendedWrite |
( |
| ) |
|
|
inline |
Convenience function for lock(LS_SuspendedWrite);.
- Returns
- True if successful
Definition at line 1466 of file xsens_mutex.h.
◆ lockWrite()
bool xsens::LockSuspendable::lockWrite |
( |
| ) |
|
|
inline |
Convenience function for lock(LS_Write);.
- Returns
- True if successful
Definition at line 1458 of file xsens_mutex.h.
◆ mutexIsSuspended()
bool xsens::LockSuspendable::mutexIsSuspended |
( |
| ) |
const volatile |
|
inline |
- Returns
- True if mutex is suspended
- Note
- This function check the current status of the mutex to tell whether it is actually suspended
Definition at line 1505 of file xsens_mutex.h.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ resume()
bool xsens::LockSuspendable::resume |
( |
| ) |
|
|
inline |
Resume a write lock.
- Returns
- True if successful or if already resuming
Definition at line 1486 of file xsens_mutex.h.
◆ suspend()
bool xsens::LockSuspendable::suspend |
( |
| ) |
|
|
inline |
Suspend a write lock, allowing readers access, but preventing others from getting a write lock.
- Returns
- True if successful or if already suspended
Definition at line 1474 of file xsens_mutex.h.
◆ unlock()
bool xsens::LockSuspendable::unlock |
( |
| ) |
|
|
inlinenoexcept |
Unlocks the write or read locked mutex.
- Returns
- True if the mutex is successfully unlocked. False if it was not locked.
Definition at line 1513 of file xsens_mutex.h.
◆ m_iSuspended
volatile std::atomic_bool xsens::LockSuspendable::m_iSuspended |
|
private |
◆ m_lockedR
volatile std::atomic_bool xsens::LockSuspendable::m_lockedR |
|
private |
◆ m_lockedW
volatile std::atomic_bool xsens::LockSuspendable::m_lockedW |
|
private |
◆ m_mutex
The documentation for this class was generated from the following file: