Public Types | Public Member Functions | Private Types | Private Attributes
Poco::AtomicCounter Class Reference

#include <AtomicCounter.h>

List of all members.

Public Types

typedef int ValueType

Public Member Functions

 AtomicCounter ()
 The underlying integer type.
 AtomicCounter (ValueType initialValue)
 Creates a new AtomicCounter and initializes it to zero.
 AtomicCounter (const AtomicCounter &counter)
 operator ValueType () const
 Assigns a value to the counter.
bool operator! () const
 Decrements the counter and returns the previous value.
ValueType operator++ ()
 Returns the value of the counter.
ValueType operator++ (int)
 Increments the counter and returns the result.
ValueType operator-- ()
 Increments the counter and returns the previous value.
ValueType operator-- (int)
 Decrements the counter and returns the result.
AtomicCounteroperator= (const AtomicCounter &counter)
 Destroys the AtomicCounter.
AtomicCounteroperator= (ValueType value)
 Assigns the value of another AtomicCounter.
ValueType value () const
 Returns the value of the counter.
 ~AtomicCounter ()
 Creates the counter by copying another one.

Private Types

typedef volatile LONG ImplType
 Returns true if the counter is zero, false otherwise.

Private Attributes

ImplType _counter

Detailed Description

This class implements a simple counter, which provides atomic operations that are safe to use in a multithreaded environment.

Typical usage of AtomicCounter is for implementing reference counting and similar things.

On some platforms, the implementation of AtomicCounter is based on atomic primitives specific to the platform (such as InterlockedIncrement, etc. on Windows), and thus very efficient. On platforms that do not support atomic primitives, operations are guarded by a FastMutex.

The following platforms currently have atomic primitives:

Definition at line 56 of file AtomicCounter.h.


Member Typedef Documentation

typedef volatile LONG Poco::AtomicCounter::ImplType [private]

Returns true if the counter is zero, false otherwise.

Definition at line 120 of file AtomicCounter.h.

Definition at line 76 of file AtomicCounter.h.


Constructor & Destructor Documentation

The underlying integer type.

Definition at line 47 of file AtomicCounter.cpp.

Creates a new AtomicCounter and initializes it to zero.

Definition at line 53 of file AtomicCounter.cpp.

Creates a new AtomicCounter and initializes it with the given value.

Definition at line 59 of file AtomicCounter.cpp.

Creates the counter by copying another one.

Definition at line 65 of file AtomicCounter.cpp.


Member Function Documentation

Poco::AtomicCounter::operator AtomicCounter::ValueType ( ) const [inline]

Assigns a value to the counter.

Definition at line 144 of file AtomicCounter.h.

bool Poco::AtomicCounter::operator! ( ) const [inline]

Decrements the counter and returns the previous value.

Definition at line 184 of file AtomicCounter.h.

AtomicCounter::ValueType Poco::AtomicCounter::operator++ ( ) [inline]

Returns the value of the counter.

Definition at line 156 of file AtomicCounter.h.

AtomicCounter::ValueType Poco::AtomicCounter::operator++ ( int  ) [inline]

Increments the counter and returns the result.

Definition at line 162 of file AtomicCounter.h.

AtomicCounter::ValueType Poco::AtomicCounter::operator-- ( ) [inline]

Increments the counter and returns the previous value.

Definition at line 170 of file AtomicCounter.h.

AtomicCounter::ValueType Poco::AtomicCounter::operator-- ( int  ) [inline]

Decrements the counter and returns the result.

Definition at line 176 of file AtomicCounter.h.

AtomicCounter & Poco::AtomicCounter::operator= ( const AtomicCounter counter)

Destroys the AtomicCounter.

Definition at line 70 of file AtomicCounter.cpp.

AtomicCounter & Poco::AtomicCounter::operator= ( AtomicCounter::ValueType  value)

Assigns the value of another AtomicCounter.

Definition at line 77 of file AtomicCounter.cpp.

Returns the value of the counter.

Definition at line 150 of file AtomicCounter.h.


Member Data Documentation

Definition at line 131 of file AtomicCounter.h.


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


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:20