A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.
It is a better idea to always use CCriticalSectionLocker, since it is more secure in the case of possible exceptions, many different exit points from a function, etc.. : it will always release the critical section at the destructor. Example:
Definition at line 89 of file CCriticalSection.h.
#include <mrpt/synch/CCriticalSection.h>
Public Member Functions | |
CCriticalSectionLocker (const CAbstractMutex *cs) | |
Constructor: enters the critical section. More... | |
CCriticalSectionLocker (const CCriticalSectionLocker &o) | |
~CCriticalSectionLocker () | |
Destructor: leaves the critical section. More... | |
Protected Attributes | |
const CAbstractMutex * | m_cs |
CCriticalSectionLocker::CCriticalSectionLocker | ( | const CAbstractMutex * | cs | ) |
Constructor: enters the critical section.
Definition at line 27 of file CCriticalSectionLocker.cpp.
References mrpt::synch::CAbstractMutex::enter(), and m_cs.
|
inline |
Definition at line 100 of file CCriticalSection.h.
CCriticalSectionLocker::~CCriticalSectionLocker | ( | ) |
Destructor: leaves the critical section.
Definition at line 42 of file CCriticalSectionLocker.cpp.
References mrpt::synch::CAbstractMutex::leave(), and m_cs.
|
protected |
Definition at line 92 of file CCriticalSection.h.
Referenced by CCriticalSectionLocker(), and ~CCriticalSectionLocker().
Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019 |