![]() |
Ark Server API (ASE) - Wiki
|
#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. | |
| AtomicCounter & | operator= (const AtomicCounter &counter) |
| Destroys the AtomicCounter. | |
| AtomicCounter & | operator= (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. | |
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.
| typedef int Poco::AtomicCounter::ValueType |
Definition at line 37 of file AtomicCounter.h.
| Poco::AtomicCounter::AtomicCounter | ( | ) |
The underlying integer type.
|
explicit |
| Poco::AtomicCounter::AtomicCounter | ( | const AtomicCounter & | counter | ) |
Creates a new AtomicCounter and initializes it with the given value.
| Poco::AtomicCounter::~AtomicCounter | ( | ) |
Creates the counter by copying another one.
|
inline |
Assigns a value to the counter.
Definition at line 88 of file AtomicCounter.h.
|
inline |
Decrements the counter and returns the previous value.
Definition at line 124 of file AtomicCounter.h.
|
inline |
Returns the value of the counter.
Definition at line 100 of file AtomicCounter.h.
Here is the caller graph for this function:
|
inline |
Increments the counter and returns the result.
Definition at line 106 of file AtomicCounter.h.
|
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:
|
inline |
Decrements the counter and returns the result.
Definition at line 118 of file AtomicCounter.h.
| AtomicCounter & Poco::AtomicCounter::operator= | ( | const AtomicCounter & | counter | ) |
Destroys the AtomicCounter.
| AtomicCounter & Poco::AtomicCounter::operator= | ( | ValueType | value | ) |
Assigns the value of another AtomicCounter.
|
inline |
Converts the AtomicCounter to ValueType.
Definition at line 94 of file AtomicCounter.h.
Here is the caller graph for this function:
|
private |
Returns true if the counter is zero, false otherwise.
Definition at line 80 of file AtomicCounter.h.