Mark3 Realtime Kernel
Mark3::LockGuard Class Reference

The LockGuard class. This class provides RAII locks based on Mark3's kernel Mutex object. Note that Mark3 does not support exceptions, so care must be taken to ensure that this object is only used where that constraint can be met. More...

#include <lockguard.h>

Public Member Functions

 LockGuard (Mutex *pclMutex)
 
 LockGuard (Mutex *pclMutex, uint32_t u32TimeoutMs_)
 
 ~LockGuard ()
 
bool isAcquired ()
 

Private Attributes

bool m_bIsAcquired
 
Mutexm_pclMutex
 

Detailed Description

The LockGuard class. This class provides RAII locks based on Mark3's kernel Mutex object. Note that Mark3 does not support exceptions, so care must be taken to ensure that this object is only used where that constraint can be met.

Definition at line 32 of file lockguard.h.

Constructor & Destructor Documentation

◆ LockGuard() [1/2]

Mark3::LockGuard::LockGuard ( Mutex pclMutex)
Parameters
pclMutexmutex to lock during construction

Definition at line 25 of file lockguard.cpp.

◆ LockGuard() [2/2]

Mark3::LockGuard::LockGuard ( Mutex pclMutex,
uint32_t  u32TimeoutMs_ 
)
Parameters
pclMutexmutex to lock during construction
u32TimeoutMs_timeout (in ms) to wait before bailng

Definition at line 34 of file lockguard.cpp.

◆ ~LockGuard()

Mark3::LockGuard::~LockGuard ( )

Definition at line 42 of file lockguard.cpp.

Member Function Documentation

◆ isAcquired()

bool Mark3::LockGuard::isAcquired ( )
inline

Verify that lock was correctly initialized and locked during acquisition. This is used to provide error-checking for timed RAII locks, where Mark3 does not use exceptions, and a kernel-panic is too heavy-handed.

Returns
true if the lock was initialed correctly, false on error

Definition at line 54 of file lockguard.h.

Member Data Documentation

◆ m_bIsAcquired

bool Mark3::LockGuard::m_bIsAcquired
private

Definition at line 57 of file lockguard.h.

◆ m_pclMutex

Mutex* Mark3::LockGuard::m_pclMutex
private

Definition at line 58 of file lockguard.h.


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