Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
Poco::AtomicCounter Class Reference

#include <AtomicCounter.h>

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)
 
 ~AtomicCounter ()
 Creates the counter by copying another one.
 
AtomicCounteroperator= (const AtomicCounter &counter)
 Destroys the AtomicCounter.
 
AtomicCounteroperator= (ValueType value)
 Assigns the value of another AtomicCounter.
 
 operator ValueType () const
 Assigns a value to the counter.
 
ValueType value () const
 Converts the AtomicCounter to ValueType.
 
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.
 
bool operator! () const
 Decrements the counter and returns the previous value.
 

Private Attributes

std::atomic< int > _counter
 Returns true if the counter is zero, false otherwise.
 

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 functionality.

Definition at line 28 of file AtomicCounter.h.

Member Typedef Documentation

◆ ValueType

Definition at line 37 of file AtomicCounter.h.

Constructor & Destructor Documentation

◆ AtomicCounter() [1/3]

Poco::AtomicCounter::AtomicCounter ( )

The underlying integer type.

◆ AtomicCounter() [2/3]

Poco::AtomicCounter::AtomicCounter ( ValueType initialValue)
explicit

Creates a new AtomicCounter and initializes it to zero.

+ Here is the caller graph for this function:

◆ AtomicCounter() [3/3]

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

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

◆ ~AtomicCounter()

Poco::AtomicCounter::~AtomicCounter ( )

Creates the counter by copying another one.

Member Function Documentation

◆ operator ValueType()

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

Assigns a value to the counter.

Definition at line 88 of file AtomicCounter.h.

◆ operator!()

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

Decrements the counter and returns the previous value.

Definition at line 124 of file AtomicCounter.h.

◆ operator++() [1/2]

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

Returns the value of the counter.

Definition at line 100 of file AtomicCounter.h.

+ Here is the caller graph for this function:

◆ operator++() [2/2]

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

Increments the counter and returns the result.

Definition at line 106 of file AtomicCounter.h.

◆ operator--() [1/2]

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

Increments the counter and returns the previous value.

Definition at line 112 of file AtomicCounter.h.

+ Here is the caller graph for this function:

◆ operator--() [2/2]

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

Decrements the counter and returns the result.

Definition at line 118 of file AtomicCounter.h.

◆ operator=() [1/2]

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

Destroys the AtomicCounter.

◆ operator=() [2/2]

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

Assigns the value of another AtomicCounter.

◆ value()

AtomicCounter::ValueType Poco::AtomicCounter::value ( ) const
inline

Converts the AtomicCounter to ValueType.

Definition at line 94 of file AtomicCounter.h.

+ Here is the caller graph for this function:

Member Data Documentation

◆ _counter

std::atomic<int> Poco::AtomicCounter::_counter
private

Returns true if the counter is zero, false otherwise.

Definition at line 80 of file AtomicCounter.h.


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