template<class T>
AtomicBase struct
Derived classes
-
template<class T>struct Atomic
Constructors, destructors, conversion operators
- AtomicBase(T value = {})
- AtomicBase(AtomicDirectInitTag, T value)
- AtomicBase(const AtomicBase& rhs)
- operator T() const
Public functions
- auto operator=(const AtomicBase& rhs) -> AtomicBase&
- auto operator=(T value) -> AtomicBase&
- auto load() const -> T
- Load the current value, as if with memory_order_relaxed.
- void store(T value)
- Store a new value, as if with memory_order_relaxed.
- void storeNonAtomic(T value)
- Non-atomically store a new value.
- auto exchange(T value) -> T
- auto compareExchange(T expected, T desired, T* original = nullptr) -> bool
Function documentation
template<class T>
sead:: AtomicBase<T>:: AtomicBase(AtomicDirectInitTag,
T value)
Directly initialises the underlying atomic with the specified value. Note that initialisation is not atomic.
template<class T>
T sead:: AtomicBase<T>:: exchange(T value)
| Returns | the previous value |
|---|
Exchange/swap the current value, as if with memory_order_relaxed.
template<class T>
bool sead:: AtomicBase<T>:: compareExchange(T expected,
T desired,
T* original = nullptr)
| Parameters | |
|---|---|
| expected | The value expected to be found in the atomic object, and to be replaced. |
| desired | The new value to store in the atomic object if expected was found. |
| original | The value that was found in the atomic object if the comparison fails. May be null. Note that this is only updated when false is returned. |
| Returns | true if and only if the value was modified |
Load the current value and if it is equal to expected, store desired as if with memory_order_relaxed. Otherwise, this sets original to the current value.