CppELib 1.7.0
Loading...
Searching...
No Matches
OSWrapper::LockGuard Class Reference

RAII wrapper of Mutex. More...

#include <Mutex.h>

Classes

struct  AdoptLock
 

Public Member Functions

 LockGuard (Mutex *m)
 Constructor of LockGuard with automatic mutex locking.
 
 LockGuard (Mutex *m, AdoptLock adoptLock)
 Constructor of LockGuard using locked Mutex object.
 
 ~LockGuard ()
 Destructor of LockGuard.
 

Static Public Attributes

static const AdoptLock ADOPT_LOCK
 Used as argument of LockGuard's constructor.
 

Detailed Description

RAII wrapper of Mutex.

A LockGuard object is used as a local variable. While the LockGuard object exists in the scope, the current thread is locking the Mutex. When it goes out of the scope and the LockGuard object ends its life, the Mutex is unlocked automatically.

Constructor & Destructor Documentation

◆ LockGuard() [1/2]

OSWrapper::LockGuard::LockGuard ( Mutex m)
explicit

Constructor of LockGuard with automatic mutex locking.

Parameters
mMutex object that the current thread has not locked

This constructor calls lock() for the Mutex object.

◆ LockGuard() [2/2]

OSWrapper::LockGuard::LockGuard ( Mutex m,
AdoptLock  adoptLock 
)

Constructor of LockGuard using locked Mutex object.

Parameters
mMutex object that the current thread has already locked by the lock methods, for example tryLock() or timedLock()
adoptLockSpecify LockGuard::ADOPT_LOCK

◆ ~LockGuard()

OSWrapper::LockGuard::~LockGuard ( )

Destructor of LockGuard.

Destructor calls unlock() for the locked Mutex object.

Member Data Documentation

◆ ADOPT_LOCK

const LockGuard::AdoptLock OSWrapper::LockGuard::ADOPT_LOCK
static

Used as argument of LockGuard's constructor.


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