SDL_SetAtomicInt(3)
π NAME π
okay bestie, gather round β SDL_SetAtomicInt is the one that sets an atomic variable to a value. that's it. that's the whole job. she's simple, she's powerful, she's iconic. π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_atomic.h>
int SDL_SetAtomicInt(SDL_AtomicInt *a, int v);
like. look at her. two args, one return, zero drama. π¦
πΈ DESCRIPTION πΈ
so basically this function also acts as a full memory barrier. that part is lowkey the whole point, bestie β it's not just "assign a number," it's "assign a number and make sure everything before and after plays nice in the right order." main character behavior, no cap. π
Note: If you don't know what this function is for, you shouldn't use it! π fr fr, this is not the vibe-check-and-see option. if you have to ask, the answer is no.
π«Ά FUNCTION PARAMETERS π«Ά
aβ a pointer to anSDL_AtomicIntvariable to be modified. that's the glow-up target. β¨vβ the desired value. the new fit. the makeover. π
π₯ RETURN VALUE π₯
Returns the previous value of the atomic variable. she gives you receipts, okay? so you always know what it was before you changed it. very considerate of her honestly. π
π THREAD SAFETY π
It is safe to call this function from any thread. every thread. all of them. they can all pull up at the same time and it's fine. π§β¨
β AVAILABILITY β
This function is available since SDL 3.2.0. so if you're on anything older, bestie, it's giving "not in your version." π upgrade era.
π SEE ALSO π
SDL_GetAtomicInt(3)β the other half of the duo. read the value, write the value, slay the value. π
kisses and full memory barriers, babes β this lil page came from Simple Directmedia Layer, running SDL 3.4.18. go forth and atomically set ur ints, you gorgeous little multithreaded gremlin π¦ππΈ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms