Main MRPT website > C++ reference for MRPT 1.5.5
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
mrpt::synch::CAtomicCounter Class Reference

Detailed Description

This class acts exactly as an int (or long) variable, but with atomic increment and decrement operators.

This is a useful component of thread-safe smart pointers.

Note
Based on code from the Boost library.

Definition at line 37 of file atomic_incr.h.

#include <mrpt/synch/atomic_incr.h>

Public Types

typedef long atomic_num_t
 

Public Member Functions

 CAtomicCounter (long v)
 
void operator++ ()
 Atomic increment of value. More...
 
atomic_num_t operator-- ()
 Atomic decrement of value and return new value. More...
 
 operator atomic_num_t () const
 Get current value. More...
 

Private Member Functions

 CAtomicCounter (CAtomicCounter const &)
 Forbidden method. More...
 
CAtomicCounteroperator= (CAtomicCounter const &)
 Forbidden method. More...
 

Private Attributes

atomic_num_t m_value
 

Member Typedef Documentation

◆ atomic_num_t

Definition at line 43 of file atomic_incr.h.

Constructor & Destructor Documentation

◆ CAtomicCounter() [1/2]

mrpt::synch::CAtomicCounter::CAtomicCounter ( long  v)
inlineexplicit

Definition at line 48 of file atomic_incr.h.

◆ CAtomicCounter() [2/2]

mrpt::synch::CAtomicCounter::CAtomicCounter ( CAtomicCounter const &  )
private

Forbidden method.

Member Function Documentation

◆ operator atomic_num_t()

CAtomicCounter::operator CAtomicCounter::atomic_num_t ( ) const

Get current value.

Definition at line 105 of file atomic_incr.cpp.

References m_value.

◆ operator++()

void CAtomicCounter::operator++ ( )

Atomic increment of value.

Definition at line 95 of file atomic_incr.cpp.

References m_value.

◆ operator--()

CAtomicCounter::atomic_num_t CAtomicCounter::operator-- ( )

Atomic decrement of value and return new value.

Definition at line 100 of file atomic_incr.cpp.

References m_value.

◆ operator=()

CAtomicCounter& mrpt::synch::CAtomicCounter::operator= ( CAtomicCounter const &  )
private

Forbidden method.

Member Data Documentation

◆ m_value

atomic_num_t mrpt::synch::CAtomicCounter::m_value
mutableprivate

Definition at line 56 of file atomic_incr.h.

Referenced by operator atomic_num_t(), operator++(), and operator--().




Page generated by Doxygen 1.8.14 for MRPT 1.5.5 Git: e06b63dbf Fri Dec 1 14:41:11 2017 +0100 at lun oct 28 01:31:35 CET 2019