sdlCompareAndSwapAtomicInt function

bool sdlCompareAndSwapAtomicInt(
  1. Pointer<SdlAtomicInt> a,
  2. int oldval,
  3. int newval
)

Set an atomic variable to a new value if it is currently an old value.

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

\param a a pointer to an SDL_AtomicInt variable to be modified. \param oldval the old value. \param newval the new value. \returns true if the atomic variable was set, false otherwise.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.1.3.

\sa SDL_GetAtomicInt \sa SDL_SetAtomicInt

extern SDL_DECLSPEC bool SDLCALL SDL_CompareAndSwapAtomicInt(SDL_AtomicInt *a, int oldval, int newval)

Implementation

bool sdlCompareAndSwapAtomicInt(
    Pointer<SdlAtomicInt> a, int oldval, int newval) {
  final sdlCompareAndSwapAtomicIntLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<SdlAtomicInt> a, Int32 oldval, Int32 newval),
      int Function(Pointer<SdlAtomicInt> a, int oldval,
          int newval)>('SDL_CompareAndSwapAtomicInt');
  return sdlCompareAndSwapAtomicIntLookupFunction(a, oldval, newval) == 1;
}