Main MRPT website > C++ reference for MRPT 1.5.6
CCriticalSectionLocker.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 
14 #include <mrpt/utils/CStream.h>
15 
16 #include <iostream>
17 
18 using namespace mrpt::utils;
19 using namespace mrpt::synch;
20 using namespace std;
21 
22 #define CS_LOCKER_VERBOSE 0
23 
24 /*---------------------------------------------------------------
25  CCriticalSectionLocker
26 ---------------------------------------------------------------*/
27 CCriticalSectionLocker::CCriticalSectionLocker( const CAbstractMutex * cs)
28  : m_cs(cs)
29 {
30  if (m_cs)
31  {
32 #if CS_LOCKER_VERBOSE
33  cout << "[CCriticalSectionLocker] Locking " << static_cast<const void*>(m_cs) << ": " << m_cs->getName() << endl;
34 #endif
35  m_cs->enter();
36  }
37 }
38 
39 /*---------------------------------------------------------------
40  ~CCriticalSectionLocker
41 ---------------------------------------------------------------*/
43 {
44  if (m_cs)
45  {
46 #if CS_LOCKER_VERBOSE
47  cout << "[CCriticalSectionLocker] Unlocking " << static_cast<const void*>(m_cs) << ": " << m_cs->getName() << endl;
48 #endif
49  m_cs->leave();
50  }
51 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
STL namespace.
virtual void leave() const =0
virtual void enter() const =0
This namespace provides multitask, synchronization utilities.
Definition: atomic_incr.h:29
~CCriticalSectionLocker()
Destructor: leaves the critical section.



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019