Simple class to hold a primitive value and perform atomic operations on it. More...
Public Member Functions | |
| Atomic () noexcept | |
| Creates a new value, initialised to zero. | |
| Atomic (const Type initialValue) noexcept | |
| Creates a new value, with a given initial value. | |
| Atomic (const Atomic &other) noexcept | |
| Copies another value (atomically). | |
| ~Atomic () noexcept | |
| Destructor. | |
| Type | get () const noexcept |
| Atomically reads and returns the current value. | |
| Atomic & | operator= (const Atomic &other) noexcept |
| Copies another value onto this one (atomically). | |
| Atomic & | operator= (const Type newValue) noexcept |
| Copies another value onto this one (atomically). | |
| void | set (Type newValue) noexcept |
| Atomically sets the current value. | |
| Type | exchange (Type value) noexcept |
| Atomically sets the current value, returning the value that was replaced. | |
| Type | operator+= (Type amountToAdd) noexcept |
| Atomically adds a number to this value, returning the new value. | |
| Type | operator-= (Type amountToSubtract) noexcept |
| Atomically subtracts a number from this value, returning the new value. | |
| Type | operator++ () noexcept |
| Atomically increments this value, returning the new value. | |
| Type | operator-- () noexcept |
| Atomically decrements this value, returning the new value. | |
| bool | compareAndSetBool (Type newValue, Type valueToCompare) noexcept |
| Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value. | |
| Type | compareAndSetValue (Type newValue, Type valueToCompare) noexcept |
| Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value. | |
| Atomic () noexcept | |
| Creates a new value, initialised to zero. | |
| Atomic (const Type initialValue) noexcept | |
| Creates a new value, with a given initial value. | |
| Atomic (const Atomic &other) noexcept | |
| Copies another value (atomically). | |
| ~Atomic () noexcept | |
| Destructor. | |
| Type | get () const noexcept |
| Atomically reads and returns the current value. | |
| Atomic & | operator= (const Atomic &other) noexcept |
| Copies another value onto this one (atomically). | |
| Atomic & | operator= (const Type newValue) noexcept |
| Copies another value onto this one (atomically). | |
| void | set (Type newValue) noexcept |
| Atomically sets the current value. | |
| Type | exchange (Type value) noexcept |
| Atomically sets the current value, returning the value that was replaced. | |
| Type | operator+= (Type amountToAdd) noexcept |
| Atomically adds a number to this value, returning the new value. | |
| Type | operator-= (Type amountToSubtract) noexcept |
| Atomically subtracts a number from this value, returning the new value. | |
| Type | operator++ () noexcept |
| Atomically increments this value, returning the new value. | |
| Type | operator-- () noexcept |
| Atomically decrements this value, returning the new value. | |
| bool | compareAndSetBool (Type newValue, Type valueToCompare) noexcept |
| Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value. | |
| Type | compareAndSetValue (Type newValue, Type valueToCompare) noexcept |
| Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value. | |
| Atomic () noexcept | |
| Creates a new value, initialised to zero. | |
| Atomic (const Type initialValue) noexcept | |
| Creates a new value, with a given initial value. | |
| Atomic (const Atomic &other) noexcept | |
| Copies another value (atomically). | |
| ~Atomic () noexcept | |
| Destructor. | |
| Type | get () const noexcept |
| Atomically reads and returns the current value. | |
| Atomic & | operator= (const Atomic &other) noexcept |
| Copies another value onto this one (atomically). | |
| Atomic & | operator= (const Type newValue) noexcept |
| Copies another value onto this one (atomically). | |
| void | set (Type newValue) noexcept |
| Atomically sets the current value. | |
| Type | exchange (Type value) noexcept |
| Atomically sets the current value, returning the value that was replaced. | |
| Type | operator+= (Type amountToAdd) noexcept |
| Atomically adds a number to this value, returning the new value. | |
| Type | operator-= (Type amountToSubtract) noexcept |
| Atomically subtracts a number from this value, returning the new value. | |
| Type | operator++ () noexcept |
| Atomically increments this value, returning the new value. | |
| Type | operator-- () noexcept |
| Atomically decrements this value, returning the new value. | |
| bool | compareAndSetBool (Type newValue, Type valueToCompare) noexcept |
| Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value. | |
| Type | compareAndSetValue (Type newValue, Type valueToCompare) noexcept |
| Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value. | |
Static Public Member Functions | |
| static void | memoryBarrier () noexcept |
| Implements a memory read/write barrier. | |
| static void | memoryBarrier () noexcept |
| Implements a memory read/write barrier. | |
| static void | memoryBarrier () noexcept |
| Implements a memory read/write barrier. | |
Public Attributes | |
| volatile Type | value |
| The raw value that this class operates on. | |
Simple class to hold a primitive value and perform atomic operations on it.
The type used must be a 32 or 64 bit primitive, like an int, pointer, etc. There are methods to perform most of the basic atomic operations.
|
noexcept |
Creates a new value, initialised to zero.
|
noexcept |
Creates a new value, with a given initial value.
|
noexcept |
Copies another value (atomically).
|
noexcept |
Destructor.
|
noexcept |
Creates a new value, initialised to zero.
|
noexcept |
Creates a new value, with a given initial value.
|
noexcept |
Copies another value (atomically).
|
noexcept |
Destructor.
|
noexcept |
Creates a new value, initialised to zero.
|
noexcept |
Creates a new value, with a given initial value.
|
noexcept |
Copies another value (atomically).
|
noexcept |
Destructor.
|
noexcept |
Atomically reads and returns the current value.
|
noexcept |
Copies another value onto this one (atomically).
|
noexcept |
Copies another value onto this one (atomically).
|
noexcept |
Atomically sets the current value.
|
noexcept |
Atomically sets the current value, returning the value that was replaced.
|
noexcept |
Atomically adds a number to this value, returning the new value.
|
noexcept |
Atomically subtracts a number from this value, returning the new value.
|
noexcept |
Atomically increments this value, returning the new value.
|
noexcept |
Atomically decrements this value, returning the new value.
|
noexcept |
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value.
This operation is the atomic equivalent of doing this:
|
noexcept |
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value.
This operation is the atomic equivalent of doing this:
|
staticnoexcept |
Implements a memory read/write barrier.
|
noexcept |
Atomically reads and returns the current value.
|
noexcept |
Copies another value onto this one (atomically).
|
noexcept |
Copies another value onto this one (atomically).
|
noexcept |
Atomically sets the current value.
|
noexcept |
Atomically sets the current value, returning the value that was replaced.
|
noexcept |
Atomically adds a number to this value, returning the new value.
|
noexcept |
Atomically subtracts a number from this value, returning the new value.
|
noexcept |
Atomically increments this value, returning the new value.
|
noexcept |
Atomically decrements this value, returning the new value.
|
noexcept |
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value.
This operation is the atomic equivalent of doing this:
|
noexcept |
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value.
This operation is the atomic equivalent of doing this:
|
staticnoexcept |
Implements a memory read/write barrier.
|
noexcept |
Atomically reads and returns the current value.
|
noexcept |
Copies another value onto this one (atomically).
|
noexcept |
Copies another value onto this one (atomically).
|
noexcept |
Atomically sets the current value.
|
noexcept |
Atomically sets the current value, returning the value that was replaced.
|
noexcept |
Atomically adds a number to this value, returning the new value.
|
noexcept |
Atomically subtracts a number from this value, returning the new value.
|
noexcept |
Atomically increments this value, returning the new value.
|
noexcept |
Atomically decrements this value, returning the new value.
|
noexcept |
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value.
This operation is the atomic equivalent of doing this:
|
noexcept |
Atomically compares this value with a target value, and if it is equal, sets this to be equal to a new value.
This operation is the atomic equivalent of doing this:
|
staticnoexcept |
Implements a memory read/write barrier.
| volatile Type Atomic< Type >::value |
The raw value that this class operates on.
This is exposed publically in case you need to manipulate it directly for performance reasons.