Base Framework
|
#include <base/concurrency/AtomicCounter.h>
Public Types | |
enum | { DEFAULT_VALUE = 0, DESTRUCT_VALUE = -1 } |
Public Member Functions | |
AtomicCounter (const TYPE _value=DEFAULT_VALUE) noexcept | |
AtomicCounter (const AtomicCounter &_value) noexcept | |
AtomicCounter & | operator= (const AtomicCounter &_value) noexcept |
operator TYPE () const noexcept | |
TYPE | operator++ (int) noexcept |
TYPE | operator++ () noexcept |
TYPE | operator-- (int) noexcept |
TYPE | operator-- () noexcept |
TYPE | operator+= (const TYPE _value) noexcept |
TYPE | operator-= (const TYPE _value) noexcept |
AtomicCounter & | operator= (const TYPE _value) noexcept |
bool | operator== (const TYPE _value) const noexcept |
bool | operator!= (const TYPE _value) const noexcept |
TYPE | exchange (const TYPE desired) noexcept |
bool | compareAndExchange (TYPE &expected, const TYPE desired) noexcept |
bool | compareAndExchangeWeak (TYPE &expected, const TYPE desired) noexcept |
Atomic counter.
MT-safe counter. Try to avoid atomic load() if result is already available from previous operation. It is recommended to use signed types to make it easier to detect problems around 0.
Make sure to use common alignment for the given type.
|
inlinenoexcept |
Initializes the counter with 0.
value | The initial value. |
|
inlinenoexcept |
Copy constructor. Avoid this.
|
inlinenoexcept |
Strong compare and exchange.
|
inlinenoexcept |
Weak compare and exchange. Prefer strong if unsure.
|
inlinenoexcept |
Exchange the value with the given value.
|
inlinenoexcept |
Returns the value of the counter.
|
inlinenoexcept |
Returns true if not equal to value.
|
inlinenoexcept |
Pre-increments the counter.
|
inlinenoexcept |
Post-increments the counter. Prefer pre-increment.
|
inlinenoexcept |
Increment counter by value.
|
inlinenoexcept |
Pre-decrements the counter.
|
inlinenoexcept |
Post-decrements the counter. Prefer pre-decrement.
|
inlinenoexcept |
Decrement counter by value.
|
inlinenoexcept |
Assignment. Avoid this.
|
inlinenoexcept |
Assign value to counter.
|
inlinenoexcept |
Returns true if equal to value.