An object oriented wrapper around a shared mutex (multiple readers allowed, but only one writer with exclusive access).
More...
#include <Mutex.hpp>
An object oriented wrapper around a shared mutex (multiple readers allowed, but only one writer with exclusive access).
A mutex can only be unlock()'ed, by the thread which lock()'ed it. A trylock is a non blocking lock action which fails or succeeds.
Implementation is motivated by http://preshing.com/20150316/semaphores-are-surprisingly-versatile/#a-lightweight-semaphore-with-partial-spinning.
- See also
- MutexLock, MutexTryLock, SharedMutexLock, SharedMutexTryLock, Mutex
Definition at line 346 of file Mutex.hpp.
RTT::os::SharedMutex::SharedMutex |
( |
| ) |
|
|
inline |
virtual RTT::os::SharedMutex::~SharedMutex |
( |
| ) |
|
|
inlinevirtual |
virtual void RTT::os::SharedMutex::lock |
( |
| ) |
|
|
inlinevirtual |
void RTT::os::SharedMutex::lock_shared |
( |
| ) |
|
|
inlinevirtual |
static unsigned int RTT::os::SharedMutex::readers |
( |
Status |
status | ) |
|
|
inlinestaticprotected |
virtual bool RTT::os::SharedMutex::timedlock |
( |
Seconds |
s | ) |
|
|
inlinevirtual |
Lock this mutex exclusively, but don't wait longer for the lock than the specified timeout.
- Parameters
-
s | The maximum time to wait before aqcuiring the lock. |
- Note
- not implemented for this type of mutex
- Returns
- false
Implements RTT::os::MutexInterface.
Definition at line 448 of file Mutex.hpp.
virtual bool RTT::os::SharedMutex::timedlock_shared |
( |
Seconds |
s | ) |
|
|
inlinevirtual |
Attempt to obtain shared ownership of this mutex, but don't wait longer for the lock than the specified timeout.
- Parameters
-
s | The maximum time to wait before aqcuiring the lock. |
- Note
- not implemented for this type of mutex
- Returns
- false
Reimplemented from RTT::os::MutexInterface.
Definition at line 515 of file Mutex.hpp.
virtual bool RTT::os::SharedMutex::trylock |
( |
| ) |
|
|
inlinevirtual |
virtual bool RTT::os::SharedMutex::trylock_shared |
( |
| ) |
|
|
inlinevirtual |
Attempt to obtain shared ownership of this mutex
- Note
- not implemented for this type of mutex
- Returns
- false
Reimplemented from RTT::os::MutexInterface.
Definition at line 501 of file Mutex.hpp.
virtual void RTT::os::SharedMutex::unlock |
( |
| ) |
|
|
inlinevirtual |
virtual void RTT::os::SharedMutex::unlock_shared |
( |
| ) |
|
|
inlinevirtual |
static unsigned int RTT::os::SharedMutex::waitToRead |
( |
Status |
status | ) |
|
|
inlinestaticprotected |
static unsigned int RTT::os::SharedMutex::writers |
( |
Status |
status | ) |
|
|
inlinestaticprotected |
const Status RTT::os::SharedMutex::one_reader = (1 << 0) |
|
staticprotected |
const Status RTT::os::SharedMutex::one_wait_to_read = (1 << 10) |
|
staticprotected |
const Status RTT::os::SharedMutex::one_writer = (1 << 20) |
|
staticprotected |
Semaphore RTT::os::SharedMutex::read_semaphore |
|
protected |
const Status RTT::os::SharedMutex::status_mask = (1 << 10) - 1 |
|
staticprotected |
Semaphore RTT::os::SharedMutex::write_semaphore |
|
protected |
The documentation for this class was generated from the following file: