GNU CommonC++
Public Member Functions | List of all members
ost::AtomicCounter Class Reference

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

#include <thread.h>

Public Member Functions

 AtomicCounter ()
 Initialize an atomic counter to 0.
 
 AtomicCounter (int value)
 Initialize an atomic counter to a known value.
 
 ~AtomicCounter ()
 
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)
 
 operator int ()
 

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.

Constructor & Destructor Documentation

◆ AtomicCounter() [1/2]

ost::AtomicCounter::AtomicCounter ( )

Initialize an atomic counter to 0.

◆ AtomicCounter() [2/2]

ost::AtomicCounter::AtomicCounter ( int  value)

Initialize an atomic counter to a known value.

Parameters
valueinitial value.

◆ ~AtomicCounter()

ost::AtomicCounter::~AtomicCounter ( )

Member Function Documentation

◆ operator int()

ost::AtomicCounter::operator int ( )

◆ operator!()

bool ost::AtomicCounter::operator! ( void  )

◆ operator+()

int ost::AtomicCounter::operator+ ( int  change)

◆ operator++()

int ost::AtomicCounter::operator++ ( void  )

◆ operator+=()

int ost::AtomicCounter::operator+= ( int  change)

◆ operator-()

int ost::AtomicCounter::operator- ( int  change)

◆ operator--()

int ost::AtomicCounter::operator-- ( void  )

◆ operator-=()

int ost::AtomicCounter::operator-= ( int  change)

◆ operator=()

int ost::AtomicCounter::operator= ( int  value)

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