logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

SDL_AtomicU32 - A type representing an atomic unsigned 32-bit value.

Availability

       This struct is available since SDL 3.2.0.

Description

       This  can  be  used to manage a value that is synchronized across multiple CPUs without a race condition;
       when an app sets a value with SDL_SetAtomicU32 all other threads, regardless of the CPU it is running on,
       will see that value when retrieved with SDL_GetAtomicU32, regardless of CPU caches, etc.

       This is also useful for atomic compare-and-swap operations: a thread can change the value as long as  its
       current  value  matches  expectations.  When  done  in  a loop, one can guarantee data consistency across
       threads without a lock (but the usual warnings apply: if you don't know what you're doing, or  you  don't
       do  it  carefully,  you  can  confidently  cause any number of disasters with this, so in most cases, you
       _should_ use a mutex instead of this!).

       This is a struct so people don't accidentally use numeric operations on it directly. You have to use  SDL
       atomic functions.

Name

       SDL_AtomicU32 - A type representing an atomic unsigned 32-bit value.

See Also

SDL_CompareAndSwapAtomicU32(3), SDL_GetAtomicU32(3), SDL_SetAtomicU32(3)

Simple Directmedia Layer                           SDL 3.2.20                               SDL_AtomicU32(3type)

Synopsis

#include<SDL3/SDL_atomic.h>typedefstructSDL_AtomicU32{Uint32value;}SDL_AtomicU32;

See Also