FreeRTOS C++ Wrappers  1.6.0
C++ interface to FreeRTOS
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cpp_freertos::LockGuard Class Reference

#include <mutex.hpp>

Collaboration diagram for cpp_freertos::LockGuard:
Collaboration graph
[legend]

Public Member Functions

 LockGuard (Mutex &m)
 
 ~LockGuard ()
 

Private Member Functions

 LockGuard (const LockGuard &)
 

Private Attributes

Mutexmutex
 

Detailed Description

Synchronization helper class that leverages the C++ language to help prevent deadlocks. This is a C++11 feature that allows Mutex Locking and Unlocking to behave following an RAII style. The constructor of this helper object locks the Mutex. The destructor unlocks the Mutex. Since C++ guarantees that an object's desctuctor is always called when it goes out of scope, calls to Unlock become unnecessary and are in fact guaranteed as long as correct scoping is used.

Definition at line 262 of file mutex.hpp.

Constructor & Destructor Documentation

◆ LockGuard() [1/2]

LockGuard::LockGuard ( Mutex m)
explicit

Create a LockGuard with a specific Mutex.

Postcondition
The Mutex will be locked.
Note
There is an infinite timeout for acquiring the Lock.

Definition at line 117 of file cmutex.cpp.

◆ ~LockGuard()

LockGuard::~LockGuard ( )

Destroy a LockGuard.

Postcondition
The Mutex will be unlocked.

Definition at line 124 of file cmutex.cpp.

◆ LockGuard() [2/2]

cpp_freertos::LockGuard::LockGuard ( const LockGuard )
private

We do not want a copy constructor.

Member Data Documentation

◆ mutex

Mutex& cpp_freertos::LockGuard::mutex
private

Reference to the Mutex we locked, so it can be unlocked in the destructor.

Definition at line 300 of file mutex.hpp.


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