Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
xsens::GuardedMutex Class Reference

A two-layer mutex, typically used for status+data protection. More...

#include <xsens_mutex.h>

Inheritance diagram for xsens::GuardedMutex:
Inheritance graph
[legend]

Public Member Functions

bool claimMutex ()
 
 GuardedMutex ()
 Constructor. More...
 
bool isUsing (Mutex const *mutex) const
 Check if the guarded mutex is equal to the supplied mutex. More...
 
bool releaseMutex ()
 
int status () const volatile
 
MutexReadWriteSuspendablesuspendable ()
 
 ~GuardedMutex ()
 Destructor. More...
 

Protected Member Functions

bool haveReadClaim () const volatile
 
bool haveWriteClaim () const volatile
 

Private Member Functions

 GuardedMutex (GuardedMutex &&)=delete
 
 GuardedMutex (GuardedMutex const &)=delete
 
GuardedMutexoperator= (GuardedMutex &&)=delete
 
GuardedMutexoperator= (GuardedMutex const &)=delete
 
- Private Member Functions inherited from xsens::MutexReadWriteSuspendable
 MutexReadWriteSuspendable ()
 
int status () const volatile
 
 ~MutexReadWriteSuspendable ()
 
bool claimMutex (bool write)
 Claims (locks) a mutex for read or write modes. More...
 
bool claimMutex (Mode mode)
 Claims (locks) a mutex using a given mode. More...
 
bool downgradeToRead (bool decreaseSuspend)
 Downgrade an existing write lock to a read lock. More...
 
bool haveReadClaim () const volatile
 
bool haveWriteClaim () const volatile
 
bool releaseMutex (bool write, bool decreaseSuspendCount)
 Releases (unlocks) a mutex for read or write modes. More...
 
bool releaseMutex (Mode mode, bool decreaseSuspendCount)
 Releases (unlocks) a mutex using a given mode. More...
 
bool resumeWriteLock ()
 Resumes an existing write lock so read locks are no longer allowed. More...
 
bool suspendWriteLock ()
 Suspend an existing write lock so read locks are allowed, but do not allow other write locks. More...
 

Private Attributes

Mutex m_guarded
 

Friends

class LockGuarded
 
class LockSuspendable
 

Additional Inherited Members

- Private Types inherited from xsens::MutexReadWriteSuspendable
enum  Mode { Mode::Read, Mode::Write, Mode::SuspendedWrite }
 An enum class that holds a three different modes of a suspendable mutex. More...
 

Detailed Description

A two-layer mutex, typically used for status+data protection.

The class provides a main suspendable mutex, which can be used for all kinds of status updates and a deeper guarded mutex, which will enforce the main mux to be locked before allowing itself to be locked.

Note
The main purpose of this is for multi-threaded data handling in which the mian mux guards the state of the device, and the guarded mux guards data access.

Definition at line 1259 of file xsens_mutex.h.

Constructor & Destructor Documentation

◆ GuardedMutex() [1/3]

xsens::GuardedMutex::GuardedMutex ( GuardedMutex const &  )
privatedelete

◆ GuardedMutex() [2/3]

xsens::GuardedMutex::GuardedMutex ( GuardedMutex &&  )
privatedelete

◆ GuardedMutex() [3/3]

xsens::GuardedMutex::GuardedMutex ( )
inline

Constructor.

Definition at line 1275 of file xsens_mutex.h.

◆ ~GuardedMutex()

xsens::GuardedMutex::~GuardedMutex ( )
inline

Destructor.

Definition at line 1281 of file xsens_mutex.h.

Member Function Documentation

◆ claimMutex()

bool xsens::GuardedMutex::claimMutex ( )
inline
Returns
true if the mutex is claimed successfully

Definition at line 1287 of file xsens_mutex.h.

◆ haveReadClaim()

bool xsens::MutexReadWriteSuspendable::haveReadClaim
inlineprotected
Returns
True if is has a read lock

Definition at line 938 of file xsens_mutex.h.

◆ haveWriteClaim()

bool xsens::MutexReadWriteSuspendable::haveWriteClaim
inlineprotected
Returns
True if is has an write lock

Definition at line 931 of file xsens_mutex.h.

◆ isUsing()

bool xsens::GuardedMutex::isUsing ( Mutex const *  mutex) const
inline

Check if the guarded mutex is equal to the supplied mutex.

Parameters
mutexThe supplied mutex
Returns
True if it is equal

Definition at line 1314 of file xsens_mutex.h.

◆ operator=() [1/2]

GuardedMutex& xsens::GuardedMutex::operator= ( GuardedMutex &&  )
privatedelete

◆ operator=() [2/2]

GuardedMutex& xsens::GuardedMutex::operator= ( GuardedMutex const &  )
privatedelete

◆ releaseMutex()

bool xsens::GuardedMutex::releaseMutex ( )
inline
Returns
true if the mutex is released successfully

Definition at line 1295 of file xsens_mutex.h.

◆ status()

int xsens::GuardedMutex::status ( ) const volatile
inline
Returns
The status of this mutex

Definition at line 1320 of file xsens_mutex.h.

◆ suspendable()

MutexReadWriteSuspendable& xsens::GuardedMutex::suspendable ( )
inline
Returns
The reference to this mutex
Note
Give access to the base class for directly checking the state of the mux

Definition at line 1305 of file xsens_mutex.h.

Friends And Related Function Documentation

◆ LockGuarded

friend class LockGuarded
friend

Definition at line 1263 of file xsens_mutex.h.

◆ LockSuspendable

friend class LockSuspendable
friend

Definition at line 1264 of file xsens_mutex.h.

Member Data Documentation

◆ m_guarded

Mutex xsens::GuardedMutex::m_guarded
private

Definition at line 1262 of file xsens_mutex.h.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:22