Bayonne2 / Common C++ 2 Framework
Public Member Functions | Private Attributes
AtomicCounter Class Reference

The AtomicCounter class offers thread-safe manipulation of an integer counter. More...

#include <thread.h>

Collaboration diagram for AtomicCounter:
Collaboration graph
[legend]

Public Member Functions

  Initialize an atomic counter to 0. More...
 
  AtomicCounter (int value)
  Initialize an atomic counter to a known value. More...
 
 
int  operator++ (void)
 
int  operator-- (void)
 
int  operator+= (int change)
 
int  operator-= (int change)
 
int  operator+ (int change)
 
int  operator- (int change)
 
int  operator= (int value)
 
bool  operator! (void)
 
 

Private Attributes

volatile int  counter
 
pthread_mutex_t  _mutex
 

Detailed Description

The AtomicCounter class offers thread-safe manipulation of an integer counter.

These are commonly used for building thread-safe "reference" counters for C++ classes. The AtomicCounter depends on the platforms support for "atomic" integer operations, and can alternately substitute a "mutex" if no atomic support exists.

Author
Sean Cavanaugh sean@.nosp@m.dime.nosp@m.nsion.nosp@m.alri.nosp@m.ft.co.nosp@m.m atomic counter operation.

Definition at line 535 of file thread.h.

Constructor & Destructor Documentation

AtomicCounter::AtomicCounter ( )

Initialize an atomic counter to 0.

AtomicCounter::AtomicCounter ( int  value )

Initialize an atomic counter to a known value.

Parameters
value initial value.
AtomicCounter::~AtomicCounter ( )

Member Function Documentation

AtomicCounter::operator int ( )
bool AtomicCounter::operator! ( void  )
int AtomicCounter::operator+ ( int  change )
int AtomicCounter::operator++ ( void  )
int AtomicCounter::operator+= ( int  change )
int AtomicCounter::operator- ( int  change )
int AtomicCounter::operator-- ( void  )
int AtomicCounter::operator-= ( int  change )
int AtomicCounter::operator= ( int  value )

Field Documentation

pthread_mutex_t AtomicCounter::_mutex
private

Definition at line 550 of file thread.h.

volatile int AtomicCounter::counter
private

Definition at line 549 of file thread.h.


The documentation for this class was generated from the following file:

Generated on Dec 21, 2017 for commoncpp2-1.8.1, ccrtp-1.7.2, libzrtpcpp-2.3.4, ccscript3-1.1.7, ccaudio2-1.0.0 and bayonne2-2.3.2 (after installation in /usr/local/) by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /