Module atomic
dep_sdl3
only.Expand description
Atomic operations.
IMPORTANT: If you are not an expert in concurrent lockless programming, you should not be using any functions in this file. You should be protecting your data structures with full mutexes instead.
Seriously, here be dragons!
You can find out a little more about lockless programming and the subtle issues that can arise here: https://learn.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming
There’s also lots of good information here:
These operations may or may not actually be implemented using processor specific atomic operations. When possible they are implemented as true processor specific atomic operations. When that is not possible the are implemented using locks that do use the available atomic operations.
All of the atomic operations that modify memory are full memory barriers.
Structs§
- SDL_
Atomic Int - A type representing an atomic integer value.
- SDL_
Atomic U32 - A type representing an atomic unsigned 32-bit value.
Functions§
- SDL_
AddAtomic ⚠Int - Add to an atomic variable.
- SDL_
Atomic ⚠DecRef - Decrement an atomic variable used as a reference count.
- SDL_
Atomic ⚠IncRef - Increment an atomic variable used as a reference count.
- SDL_
CPUPause Instruction - SDL_
Compare ⚠AndSwap Atomic Int - Set an atomic variable to a new value if it is currently an old value.
- SDL_
Compare ⚠AndSwap Atomic Pointer - Set a pointer to a new value if it is currently an old value.
- SDL_
Compare ⚠AndSwap Atomic U32 - Set an atomic variable to a new value if it is currently an old value.
- SDL_
Compiler Barrier - SDL_
GetAtomic ⚠Int - Get the value of an atomic variable.
- SDL_
GetAtomic ⚠Pointer - Get the value of a pointer atomically.
- SDL_
GetAtomic ⚠U32 - Get the value of an atomic variable.
- SDL_
Lock ⚠Spinlock - Lock a spin lock by setting it to a non-zero value.
- SDL_
Memory Barrier Acquire - SDL_
Memory ⚠Barrier Acquire Function - Insert a memory acquire barrier (function version).
- SDL_
Memory Barrier Release - SDL_
Memory ⚠Barrier Release Function - Insert a memory release barrier (function version).
- SDL_
SetAtomic ⚠Int - Set an atomic variable to a value.
- SDL_
SetAtomic ⚠Pointer - Set a pointer to a value atomically.
- SDL_
SetAtomic ⚠U32 - Set an atomic variable to a value.
- SDL_
TryLock ⚠Spinlock - Try to lock a spin lock by setting it to a non-zero value.
- SDL_
Unlock ⚠Spinlock - Unlock a spin lock by setting it to 0.
Type Aliases§
- SDL_
Spin Lock - An atomic spinlock.