Main MRPT website
>
C++ reference for MRPT 1.5.9
synch
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
13
#include <
mrpt/synch/CCriticalSection.h
>
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
---------------------------------------------------------------*/
42
CCriticalSectionLocker::~CCriticalSectionLocker
()
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
}
mrpt::utils
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition:
zip.h:16
std
STL namespace.
mrpt::synch::CCriticalSectionLocker::m_cs
const CAbstractMutex * m_cs
Definition:
CCriticalSection.h:92
mrpt::synch::CAbstractMutex::leave
virtual void leave() const =0
CStream.h
CCriticalSection.h
mrpt::synch::CAbstractMutex::enter
virtual void enter() const =0
mrpt::synch::CAbstractMutex
Definition:
CCriticalSection.h:27
mrpt::synch
This namespace provides multitask, synchronization utilities.
Definition:
CCriticalSection.h:25
mrpt::synch::CCriticalSectionLocker::~CCriticalSectionLocker
~CCriticalSectionLocker()
Destructor: leaves the critical section.
Definition:
CCriticalSectionLocker.cpp:42
base-precomp.h
Page generated by
Doxygen 1.8.14
for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020