Public Member Functions | Private Member Functions | Private Attributes | List of all members
xsens::LockGuarded Class Reference

A guarded lock class. More...

#include <xsens_mutex.h>

Public Member Functions

bool isLocked () const
 
bool isUsing (GuardedMutex const *mutex) const
 Check if the lock is using the supplied mutex. More...
 
bool isUsing (Mutex const *mutex) const
 Check if the lock is using the supplied mutex. More...
 
bool isUsing (MutexReadWriteSuspendable const *mutex) const
 Check if the lock is using the supplied mutex. More...
 
bool lock ()
 Locks the unlocked mutex. More...
 
 LockGuarded (GuardedMutex *mutex, bool lockit=true)
 Constructs a guarded lock using a guarded mutex. More...
 
 LockGuarded (GuardedMutex *mutex, LockState lockit)
 Constructs a guarded lock using a guarded mutex and a lock state. More...
 
bool unlock () noexcept
 Unlocks the locked mutex. More...
 
 ~LockGuarded ()
 Destructor. More...
 

Private Member Functions

 LockGuarded (LockGuarded &&)=delete
 
 LockGuarded (LockGuarded const &)=delete
 
LockGuardedoperator= (LockGuarded &&)=delete
 
LockGuardedoperator= (LockGuarded const &)=delete
 

Private Attributes

volatile std::atomic_bool m_locked
 
GuardedMutexm_mutex
 

Detailed Description

A guarded lock class.

Definition at line 1569 of file xsens_mutex.h.

Constructor & Destructor Documentation

◆ LockGuarded() [1/4]

xsens::LockGuarded::LockGuarded ( LockGuarded const &  )
privatedelete

◆ LockGuarded() [2/4]

xsens::LockGuarded::LockGuarded ( LockGuarded &&  )
privatedelete

◆ LockGuarded() [3/4]

xsens::LockGuarded::LockGuarded ( GuardedMutex mutex,
bool  lockit = true 
)
inline

Constructs a guarded lock using a guarded mutex.

Definition at line 1584 of file xsens_mutex.h.

◆ LockGuarded() [4/4]

xsens::LockGuarded::LockGuarded ( GuardedMutex mutex,
LockState  lockit 
)
inline

Constructs a guarded lock using a guarded mutex and a lock state.

Definition at line 1592 of file xsens_mutex.h.

◆ ~LockGuarded()

xsens::LockGuarded::~LockGuarded ( )
inline

Destructor.

Definition at line 1600 of file xsens_mutex.h.

Member Function Documentation

◆ isLocked()

bool xsens::LockGuarded::isLocked ( ) const
inline
Returns
True if the mutex is locked by this lock

Definition at line 1630 of file xsens_mutex.h.

◆ isUsing() [1/3]

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

Check if the lock is using the supplied mutex.

Parameters
mutexThe supplied guarded mutex
Returns
True if it is equal

Definition at line 1639 of file xsens_mutex.h.

◆ isUsing() [2/3]

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

Check if the lock is using the supplied mutex.

Parameters
mutexThe supplied generic mutex
Returns
True if it is equal

Definition at line 1657 of file xsens_mutex.h.

◆ isUsing() [3/3]

bool xsens::LockGuarded::isUsing ( MutexReadWriteSuspendable const *  mutex) const
inline

Check if the lock is using the supplied mutex.

Parameters
mutexThe supplied suspendable readers-writer mutex
Returns
True if it is equal

Definition at line 1648 of file xsens_mutex.h.

◆ lock()

bool xsens::LockGuarded::lock ( )
inline

Locks the unlocked mutex.

Returns
True if the mutex is successfully locked

Definition at line 1608 of file xsens_mutex.h.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ unlock()

bool xsens::LockGuarded::unlock ( )
inlinenoexcept

Unlocks the locked mutex.

Returns
True if the mutex is successfully unlocked

Definition at line 1618 of file xsens_mutex.h.

Member Data Documentation

◆ m_locked

volatile std::atomic_bool xsens::LockGuarded::m_locked
private

Definition at line 1573 of file xsens_mutex.h.

◆ m_mutex

GuardedMutex* xsens::LockGuarded::m_mutex
private

Definition at line 1572 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:23