Main MRPT website > C++ reference for MRPT 1.5.6
List of all members | Public Member Functions | Protected Attributes
mrpt::synch::CCriticalSectionLocker Class Reference

Detailed Description

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:

{ // Code in this scope is protected by critical section
CCriticalSectionLocker myCSLocker( &myCS );
...
} // End of code protected by critical section
See Also
CCriticalSection, THREADSAFE_OPERATION

Definition at line 90 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 CAbstractMutexm_cs
 

Constructor & Destructor Documentation

CCriticalSectionLocker::CCriticalSectionLocker ( const CAbstractMutex cs)

Constructor: enters the critical section.

Note
[Since MRPT 0.9.6] The pointer can be NULL, in which case no action at all will be taken.

Definition at line 27 of file CCriticalSectionLocker.cpp.

References mrpt::synch::CAbstractMutex::enter(), and m_cs.

mrpt::synch::CCriticalSectionLocker::CCriticalSectionLocker ( const CCriticalSectionLocker o)
inline

Definition at line 101 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.

Member Data Documentation

const CAbstractMutex* mrpt::synch::CCriticalSectionLocker::m_cs
protected

Definition at line 93 of file CCriticalSection.h.

Referenced by CCriticalSectionLocker(), and ~CCriticalSectionLocker().




Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018