Embedded Multicore Building Blocks V1.0.0
Public Member Functions | List of all members
embb::base::LockGuard< Mutex > Class Template Reference

Scoped lock (according to the RAII principle) using a mutex. More...

#include <mutex.h>

Public Member Functions

 LockGuard (Mutex &mutex)
 Creates the lock and locks the mutex. More...
 
 ~LockGuard ()
 Unlocks the mutex. More...
 

Detailed Description

template<typename Mutex = embb::base::Mutex>
class embb::base::LockGuard< Mutex >

Scoped lock (according to the RAII principle) using a mutex.

The mutex is locked on construction and unlocked on leaving the scope of the lock.

Template Parameters
MutexUsed mutex type. Has to fulfil the Mutex Concept.
See also
UniqueLock

Constructor & Destructor Documentation

template<typename Mutex = embb::base::Mutex>
embb::base::LockGuard< Mutex >::LockGuard ( Mutex mutex)
explicit

Creates the lock and locks the mutex.

Precondition
The given mutex is unlocked
Concurrency
Not thread-safe
Parameters
[in]mutexMutex to be guarded
template<typename Mutex = embb::base::Mutex>
embb::base::LockGuard< Mutex >::~LockGuard ( )

Unlocks the mutex.