SDL_AddAtomicInt(3)
π SDL_AddAtomicInt π
okay bestie, so this one is from the SDL3 manual (that's the SDL3 FUNCTIONS crew, iykyk) and it's called SDL_AddAtomicInt β and yes, it does exactly what it says on the tin: it adds to an atomic variable. slay.
β¨ NAME β¨
SDL_AddAtomicInt β add to an atomic variable. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_atomic.h>
int SDL_AddAtomicInt(SDL_AtomicInt *a, int v);
look at her. gorgeous. two params, one int back. main character energy fr fr. π
π¦ DESCRIPTION π¦
so like, this function adds to an atomic variable, right? but plot twist: it also acts as a full memory barrier. that's not a little side note, that's a whole extra job and she's doing it for free. π
β οΈ Note: if you don't know what this function is for, you shouldn't use it! like... genuinely. this is not a "just try it and see" situation bestie. if you don't already know why you need it, you don't need it. step away from the atomics. π«Ά
π FUNCTION PARAMETERS π
aβ a pointer to anSDL_AtomicIntvariable that's getting modified. she's the one being changed. πvβ the desired value to add. your contribution. your little gift. β¨
β RETURN VALUE β
returns the previous value of the atomic variable. not the new one β the before picture. so you get receipts of what it was, not what it became. π
π§ THREAD SAFETY π§
it is safe to call this function from any thread. any of them. all of them. go wild, no cap. π₯
π AVAILABILITY π
this function is available since SDL 3.2.0. if you're on anything older, sorry babe, she's not there yet. π
π SEE ALSO π
the ref-counting girlies. go say hi. π
and that's the whole page bestie, no crumbs left. this iconic little number comes to you courtesy of Simple Directmedia Layer, sitting pretty at version SDL 3.4.18 β mwah, love that for her. now go add something atomically, safely, and with full memory-barrier energy. periodt. π β¨πΈ
π¦ 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