Main MRPT website > C++ reference for MRPT 1.4.0
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
A class acquiring a CCriticalSection at its constructor, and releasing it at destructor.
See also
CCriticalSection, THREADSAFE_OPERATION

Definition at line 75 of file CCriticalSection.h.

#include <mrpt/synch/CCriticalSection.h>

Public Member Functions

 CCriticalSectionLocker (const CCriticalSection *cs)
 Constructor: enters the critical section.
 
 CCriticalSectionLocker (const CCriticalSectionLocker &o)
 
CCriticalSectionLockeroperator= (const CCriticalSectionLocker &o)
 
 ~CCriticalSectionLocker ()
 Destructor: leaves the critical section.
 

Protected Attributes

const CCriticalSectionm_cs
 

Constructor & Destructor Documentation

◆ CCriticalSectionLocker() [1/2]

mrpt::synch::CCriticalSectionLocker::CCriticalSectionLocker ( const CCriticalSection 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.

◆ CCriticalSectionLocker() [2/2]

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

Definition at line 86 of file CCriticalSection.h.

◆ ~CCriticalSectionLocker()

mrpt::synch::CCriticalSectionLocker::~CCriticalSectionLocker ( )

Destructor: leaves the critical section.

Member Function Documentation

◆ operator=()

CCriticalSectionLocker & mrpt::synch::CCriticalSectionLocker::operator= ( const CCriticalSectionLocker o)
inline

Definition at line 90 of file CCriticalSection.h.

References m_cs.

Member Data Documentation

◆ m_cs

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

Definition at line 78 of file CCriticalSection.h.

Referenced by operator=().




Page generated by Doxygen 1.9.8 for MRPT 1.4.0 SVN: at Fri Dec 15 05:36:48 UTC 2023