1#ifndef SDL3PP_ATOMIC_H_
2#define SDL3PP_ATOMIC_H_
4#include <SDL3/SDL_atomic.h>
5#include "SDL3pp_stdinc.h"
98#define SDL_CompilerBarrier() DoCompilerSpecificReadWriteBarrier()
136#define SDL_MemoryBarrierRelease() SDL_MemoryBarrierReleaseFunction()
159#define SDL_MemoryBarrierAcquire() SDL_MemoryBarrierAcquireFunction()
177#define SDL_CPUPauseInstruction() \
178 DoACPUPauseInACompilerAndArchitectureSpecificWay
211 SDL_AtomicInt m_value;
225 constexpr operator SDL_AtomicInt*() {
return &m_value; }
246 return SDL_CompareAndSwapAtomicInt(&m_value, oldval, newval);
266 int Set(
int v) {
return SDL_SetAtomicInt(&m_value, v); }
282 int Get() {
return SDL_GetAtomicInt(&m_value); }
302 int Add(
int v) {
return SDL_AddAtomicInt(&m_value, v); }
364 SDL_AtomicU32 m_value;
378 constexpr operator SDL_AtomicU32*() {
return &m_value; }
399 return SDL_CompareAndSwapAtomicU32(&m_value, oldval, newval);
419 Uint32
Set(Uint32 v) {
return SDL_SetAtomicU32(&m_value, v); }
435 Uint32
Get() {
return SDL_GetAtomicU32(&m_value); }
475 return SDL_CompareAndSwapAtomicPointer(&m_value, oldval, newval);
494 T*
Set(T* v) {
return SDL_SetAtomicPointer(&m_value, v); }
511 T*
Get() {
return SDL_GetAtomicPointer(&m_value); }
A type representing an atomic integer value.
Definition SDL3pp_atomic.h:210
constexpr AtomicInt(int value=0)
Constructor.
Definition SDL3pp_atomic.h:215
bool CompareAndSwap(int oldval, int newval)
Set an atomic variable to a new value if it is currently an old value.
Definition SDL3pp_atomic.h:244
int Add(int v)
Add to an atomic variable.
Definition SDL3pp_atomic.h:302
bool AtomicDecRef()
Decrement an atomic variable used as a reference count.
Definition SDL3pp_atomic.h:333
int Get()
Get the value of an atomic variable.
Definition SDL3pp_atomic.h:282
bool AtomicIncRef()
Increment an atomic variable used as a reference count.
Definition SDL3pp_atomic.h:317
int Set(int v)
Set an atomic variable to a value.
Definition SDL3pp_atomic.h:266
Type representing an atomic pointer.
Definition SDL3pp_atomic.h:441
T * Get()
Get the value of a pointer atomically.
Definition SDL3pp_atomic.h:511
T * Set(T *v)
Set a pointer to a value atomically.
Definition SDL3pp_atomic.h:494
constexpr AtomicPointer(T *value=nullptr)
Constructor.
Definition SDL3pp_atomic.h:446
bool CompareAndSwap(T *oldval, T *newval)
Set a pointer to a new value if it is currently an old value.
Definition SDL3pp_atomic.h:473
A type representing an atomic unsigned 32-bit value.
Definition SDL3pp_atomic.h:363
bool CompareAndSwap(Uint32 oldval, Uint32 newval)
Set an atomic variable to a new value if it is currently an old value.
Definition SDL3pp_atomic.h:397
constexpr AtomicU32(Uint32 value=0)
Constructor.
Definition SDL3pp_atomic.h:368
Uint32 Set(Uint32 v)
Set an atomic variable to a value.
Definition SDL3pp_atomic.h:419
Uint32 Get()
Get the value of an atomic variable.
Definition SDL3pp_atomic.h:435
void MemoryBarrierAcquire()
Insert a memory acquire barrier (function version).
Definition SDL3pp_atomic.h:78
void MemoryBarrierRelease()
Insert a memory release barrier (function version).
Definition SDL3pp_atomic.h:58
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7