A readers-writer lock class.
More...
#include <xsens_mutex.h>
A readers-writer lock class.
Definition at line 1090 of file xsens_mutex.h.
◆ LockReadWrite() [1/3]
◆ LockReadWrite() [2/3]
◆ LockReadWrite() [3/3]
◆ ~LockReadWrite()
xsens::LockReadWrite::~LockReadWrite |
( |
| ) |
|
|
inline |
◆ CHECK_LOCK_DEFINE()
xsens::LockReadWrite::CHECK_LOCK_DEFINE |
( |
| ) |
|
|
private |
◆ haveWriteClaim()
bool xsens::LockReadWrite::haveWriteClaim |
( |
| ) |
const volatile |
|
inline |
- Returns
- True if the mutex has a write lock
- Note
- Do not use this function internally! The mutex may have a write claim, while the lock does not, but this function will return true.
Definition at line 1246 of file xsens_mutex.h.
◆ isLocked()
bool xsens::LockReadWrite::isLocked |
( |
bool |
write | ) |
const volatile |
|
inline |
- Returns
- true if the lock has at least the given state
- Parameters
-
write | If set to true, write mode is used, otherwise read mode |
Definition at line 1238 of file xsens_mutex.h.
◆ lock() [1/2]
bool xsens::LockReadWrite::lock |
( |
bool |
write | ) |
|
|
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
-
write | If set to true, write mode is used, otherwise read mode |
- Returns
- True if successfully locked
Definition at line 1129 of file xsens_mutex.h.
◆ lock() [2/2]
bool xsens::LockReadWrite::lock |
( |
LockState |
ls | ) |
|
|
inline |
Convenience function that accepts the generic LockState, forwards to lock(bool)
- Parameters
-
ls | If set not to read lock state then it will lock the mutex |
- Returns
- True if successfully locked
Definition at line 1161 of file xsens_mutex.h.
◆ lockRead()
bool xsens::LockReadWrite::lockRead |
( |
| ) |
|
|
inline |
Convenience function for lock(false);.
- Returns
- True if successful
Definition at line 1169 of file xsens_mutex.h.
◆ lockWrite()
bool xsens::LockReadWrite::lockWrite |
( |
| ) |
|
|
inline |
Convenience function for lock(true);.
- Returns
- True if successful
Definition at line 1177 of file xsens_mutex.h.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ tryLock()
bool xsens::LockReadWrite::tryLock |
( |
bool |
write, |
|
|
uint32_t |
timeout = 0 |
|
) |
| |
|
inline |
Tries to lock the write/read unlocked mutex before a given time runs out.
- Parameters
-
write | If set to true, write mode is used, otherwise read mode |
timeout | The timeout value in ms |
- Returns
- True if the mutex is successfully locked
Definition at line 1207 of file xsens_mutex.h.
◆ unlock()
bool xsens::LockReadWrite::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 1185 of file xsens_mutex.h.
◆ m_lockedR
volatile std::atomic_bool xsens::LockReadWrite::m_lockedR |
|
private |
◆ m_lockedW
volatile std::atomic_bool xsens::LockReadWrite::m_lockedW |
|
private |
◆ m_mutex
The documentation for this class was generated from the following file: