A simple wrapper around std::atomic. More...
#include <juce_Atomic.h>
Public Types | |
using | DiffType = typename AtomicHelpers::DiffTypeHelper<Type>::Type |
Public Member Functions | |
Atomic () noexcept | |
Creates a new value, initialised to zero. | |
Atomic (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. | |
void | set (Type newValue) noexcept |
Atomically sets the current value. | |
Type | exchange (Type newValue) noexcept |
Atomically sets the current value, returning the value that was replaced. | |
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. | |
Atomic< Type > & | operator= (const Atomic &other) noexcept |
Copies another value into this one (atomically). | |
Atomic< Type > & | operator= (Type newValue) noexcept |
Copies another value into this one (atomically). | |
Type | operator+= (DiffType amountToAdd) noexcept |
Atomically adds a number to this value, returning the new value. | |
Type | operator-= (DiffType 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. | |
void | memoryBarrier () noexcept |
Implements a memory read/write barrier. | |
Public Attributes | |
std::atomic< Type > | value |
The std::atomic object that this class operates on. | |
A simple wrapper around std::atomic.
using Atomic< Type >::DiffType = typename AtomicHelpers::DiffTypeHelper<Type>::Type |
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(), ThreadLocalValue< Type >::releaseCurrentThreadStorage(), and ThreadLocalValue< Type >::~ThreadLocalValue().
|
noexcept |
Atomically sets the current value.
References Atomic< Type >::value.
|
noexcept |
Atomically sets the current value, returning the value that was replaced.
References Atomic< Type >::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:
Internally, this method calls std::atomic::compare_exchange_strong with memory_order_seq_cst (the strictest std::memory_order).
References Atomic< Type >::value.
Referenced by ThreadLocalValue< Type >::get().
|
noexcept |
Copies another value into this one (atomically).
References Atomic< Type >::value.
Copies another value into this one (atomically).
References Atomic< Type >::value.
Atomically adds a number to this value, returning the new value.
References Atomic< Type >::value.
Atomically subtracts a number from this value, returning the new value.
References Atomic< Type >::value.
|
noexcept |
Atomically increments this value, returning the new value.
References Atomic< Type >::value.
|
noexcept |
Atomically decrements this value, returning the new value.
References Atomic< Type >::value.
|
noexcept |
Implements a memory read/write barrier.
Internally this calls std::atomic_thread_fence with memory_order_seq_cst (the strictest std::memory_order).
std::atomic<Type> Atomic< Type >::value |
The std::atomic object that this class operates on.
Referenced by Atomic< Type >::compareAndSetBool(), Atomic< Type >::exchange(), Atomic< Type >::get(), Atomic< Type >::operator++(), Atomic< Type >::operator+=(), Atomic< Type >::operator--(), Atomic< Type >::operator-=(), Atomic< Type >::operator=(), Atomic< Type >::operator=(), and Atomic< Type >::set().