JUCE
|
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. More... | |
Atomic (const Type initialValue) noexcept | |
Creates a new value, with a given initial value. More... | |
Atomic (const Atomic &other) noexcept | |
Copies another value (atomically). More... | |
~Atomic () noexcept | |
Destructor. More... | |
Type | get () const noexcept |
Atomically reads and returns the current value. More... | |
Atomic & | operator= (const Atomic &other) noexcept |
Copies another value onto this one (atomically). More... | |
Atomic & | operator= (const Type newValue) noexcept |
Copies another value onto this one (atomically). More... | |
void | set (Type newValue) noexcept |
Atomically sets the current value. More... | |
Type | exchange (Type value) noexcept |
Atomically sets the current value, returning the value that was replaced. More... | |
Type | operator+= (Type amountToAdd) noexcept |
Atomically adds a number to this value, returning the new value. More... | |
Type | operator-= (Type amountToSubtract) noexcept |
Atomically subtracts a number from this value, returning the new value. More... | |
Type | operator++ () noexcept |
Atomically increments this value, returning the new value. More... | |
Type | operator-- () noexcept |
Atomically decrements this value, returning the new value. More... | |
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. More... | |
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. More... | |
Static Public Member Functions | |
static void | memoryBarrier () noexcept |
Implements a memory read/write barrier. More... | |
Public Attributes | |
volatile Type | value |
The raw value that this class operates on. More... | |
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.
Creates a new value, initialised to zero.
Creates a new value, with a given initial value.
Copies another value (atomically).
|
noexcept |
Atomically reads and returns the current value.
References Atomic< Type >::value.
Referenced by ThreadLocalValue< Type >::get(), and ThreadLocalValue< Type >::releaseCurrentThreadStorage().
Copies another value onto this one (atomically).
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.
References Atomic< Type >::compareAndSetBool(), and Atomic< Type >::value.
Referenced by Atomic< int >::operator=(), and Atomic< int >::set().
|
noexcept |
Atomically adds a number to this value, returning the new value.
References Atomic< Type >::value.
Referenced by Atomic< Type >::operator-=(), and Atomic< int >::set().
|
noexcept |
Atomically subtracts a number from this value, returning the new value.
References Atomic< Type >::operator+=().
Referenced by Atomic< int >::set().
|
noexcept |
Atomically increments this value, returning the new value.
References Atomic< Type >::value.
Referenced by Atomic< int >::set().
|
noexcept |
Atomically decrements this value, returning the new value.
References Atomic< Type >::value.
Referenced by Atomic< int >::set().
|
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:
References Atomic< Type >::compareAndSetValue(), and Atomic< Type >::value.
Referenced by Atomic< Type >::compareAndSetValue(), Atomic< Type >::exchange(), ThreadLocalValue< Type >::get(), and Atomic< int >::set().
|
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:
References Atomic< Type >::compareAndSetBool(), and Atomic< Type >::value.
Referenced by Atomic< Type >::compareAndSetBool(), and Atomic< int >::set().
|
staticnoexcept |
Implements a memory read/write barrier.
Referenced by Atomic< int >::set().
volatile Type Atomic< Type >::value |
The raw value that this class operates on.
This is exposed publicly in case you need to manipulate it directly for performance reasons.
Referenced by Atomic< Type >::compareAndSetBool(), Atomic< Type >::compareAndSetValue(), Atomic< Type >::exchange(), Atomic< Type >::get(), Atomic< Type >::operator++(), Atomic< Type >::operator+=(), Atomic< Type >::operator--(), Atomic< int >::set(), and ThreadLocalValue< Type >::~ThreadLocalValue().