SDL_CompareAndSwapAtomicInt(3)

✨ SDL_CompareAndSwapAtomicInt(3) ✨

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual πŸŽ€ β€” this one's called SDL_CompareAndSwapAtomicInt and it's giving very careful, very deliberate energy. No cap.


πŸ’– NAME πŸ’–

SDL_CompareAndSwapAtomicInt β€” set an atomic variable to a new value if it is currently an old value. like, only if. it's a conditional baddie. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_atomic.h>

bool SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval);

πŸ¦‹ DESCRIPTION πŸ¦‹

Note: if you don't know what this function is for, you shouldn't use it! 🫢

fr fr. this is not a "let me just try it and see" situation. if this function is a mystery to you, that's the universe telling you to walk away, bestie. it's not being mean, it's being honest. 😭

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • a β€” a pointer to an SDL_AtomicInt variable to be modified. that's the glow-up target. ✨
  • oldval β€” the old value. the one it has to be currently, or nothing happens. πŸ‘€
  • newval β€” the new value. the fit it's gonna change into. πŸ‘‘

πŸ’… RETURN VALUE πŸ’…

Returns true if the atomic variable was set, false otherwise.

so basically: true = slay, the swap happened. false = nope, it wasn't holding oldval, nothing changed. πŸ€·β™€οΈ


🌈 THREAD SAFETY 🌈

It is safe to call this function from any thread. πŸ’―

every thread, no drama, no "wait your turn". it's atomic, that's literally the whole point. main character energy that plays well with others. πŸ‘‘

⭐ AVAILABILITY ⭐

This function is available since SDL 3.2.0. πŸ—“οΈ


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole vibe check, bestie. 🧚 this page came to you from the Simple Directmedia Layer girlies, running SDL 3.4.18, and yes the manual page name is literally just SDL_CompareAndSwapAtomicInt(3) again because the header and footer are extra like that. πŸ’– stay atomic, stay iconic. πŸŽ€βœ¨

πŸ“¦ where this page comes from