MRPT logo

mrpt::synch::CCriticalSectionLocker Class Reference

A class acquiring a CCriticalSection at its constructor, and releasing it at destructor. More...

#include <mrpt/synch/CCriticalSection.h>

List of all members.

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


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

Definition at line 91 of file CCriticalSection.h.


Constructor & Destructor Documentation

mrpt::synch::CCriticalSectionLocker::CCriticalSectionLocker ( const CCriticalSection cs  ) 

Constructor: enters the critical section.

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

Definition at line 101 of file CCriticalSection.h.

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

Destructor: leaves the critical section.


Member Function Documentation

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

Definition at line 105 of file CCriticalSection.h.

References m_cs.


Member Data Documentation

Definition at line 94 of file CCriticalSection.h.

Referenced by operator=().




Page generated by Doxygen 1.5.9 for MRPT 0.7.1 SVN: at Mon Aug 17 22:32:05 EDT 2009