Main MRPT website > C++ reference for MRPT 1.5.7
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-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 #ifndef mrpt_synch_atomicincr_H
11 #define mrpt_synch_atomicincr_H
12 
13 #include <mrpt/base/link_pragmas.h> // DLL import/export definitions
14 #include <mrpt/config.h>
16 
17 namespace mrpt {
18 namespace synch {
19 
20 /** This class acts exactly as an int (or long) variable, but with atomic
21  * increment and decrement operators. This is a useful component of thread-safe
22  * smart pointers. \ingroup synch_grp
23  */
25 public:
27  explicit CAtomicCounter(long v);
28  ~CAtomicCounter();
29 
30  void operator++(); //!< Atomic increment of value.
31  long operator--(); //!< Atomic decrement of value and return new value.
32  operator long() const; //!< Get current value
33 
34 private:
35  long *m_atomic; //!< opaque ptr to C++11 std::atomic_long
36 
37  CAtomicCounter(CAtomicCounter const &); //!< Forbidden method
38  CAtomicCounter &operator=(CAtomicCounter const &); //!< Forbidden method
39 }; // end of CAtomicCounter
40 
41 } // namespace synch
42 } // namespace mrpt
43 
44 #endif
iterator operator++(int)
A thread-safe (ts) container which minimally emulates a std::map<>&#39;s [] and find() methods but which ...
Definition: ts_hash_map.h:97
const GLdouble * v
Definition: glext.h:3603
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
long * m_atomic
opaque ptr to C++11 std::atomic_long
Definition: atomic_incr.h:35
This class acts exactly as an int (or long) variable, but with atomic increment and decrement operato...
Definition: atomic_incr.h:24



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019