Main MRPT website
>
C++ reference for MRPT 1.3.2
mrpt
synch
atomic_incr.h
Go to the documentation of this file.
1
/* +---------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2015, 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
#ifndef mrpt_synch_atomicincr_H
10
#define mrpt_synch_atomicincr_H
11
12
#include <mrpt/config.h>
13
#include <
mrpt/utils/compiler_fixes.h
>
14
#include <
mrpt/base/link_pragmas.h
>
// DLL import/export definitions
15
16
namespace
mrpt
17
{
18
namespace
synch
19
{
20
21
/** This class acts exactly as an int (or long) variable, but with atomic increment and decrement operators.
22
* This is a useful component of thread-safe smart pointers.
23
* \note Based on code from the Boost library.
24
* \ingroup synch_grp
25
*/
26
class
BASE_IMPEXP
CAtomicCounter
27
{
28
public
:
29
#ifdef MRPT_OS_WINDOWS
30
typedef
long
atomic_num_t
;
31
#else
32
typedef
int
atomic_num_t
;
33
#endif
34
35
explicit
CAtomicCounter
(
long
v ): m_value( static_cast<atomic_num_t>(v) )
36
{ }
37
38
void
operator++();
//!< Atomic increment of value.
39
atomic_num_t operator--();
//!< Atomic decrement of value and return new value.
40
operator
atomic_num_t()
const
;
//!< Get current value
41
42
private
:
43
mutable
atomic_num_t
m_value
;
44
45
CAtomicCounter
(
CAtomicCounter
const
& );
//!< Forbidden method
46
CAtomicCounter
& operator=(
CAtomicCounter
const
& );
//!< Forbidden method
47
};
// end of CAtomicCounter
48
49
50
}
// End of namespace
51
}
// End of namespace
52
53
#endif
compiler_fixes.h
mrpt::synch::CAtomicCounter::CAtomicCounter
CAtomicCounter(long v)
Definition:
atomic_incr.h:35
BASE_IMPEXP
#define BASE_IMPEXP
Definition:
maps/CColouredPointsMap.h:90
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition:
CParticleFilter.h:16
mrpt::synch::CAtomicCounter::atomic_num_t
int atomic_num_t
Definition:
atomic_incr.h:32
mrpt::synch::CAtomicCounter::m_value
atomic_num_t m_value
Definition:
atomic_incr.h:43
link_pragmas.h
mrpt::synch::CAtomicCounter
This class acts exactly as an int (or long) variable, but with atomic increment and decrement operato...
Definition:
atomic_incr.h:26
Page generated by
Doxygen 1.8.12
for MRPT 1.3.2 SVN: at Thu Nov 10 13:46:27 UTC 2016