sdlAtomicCas function

bool sdlAtomicCas(
  1. Pointer<SdlAtomicT> 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_atomic_t variable to be modified \param oldval the old value \param newval the new value \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.

\since This function is available since SDL 2.0.0.

\sa SDL_AtomicCASPtr \sa SDL_AtomicGet \sa SDL_AtomicSet

extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)

Implementation

bool sdlAtomicCas(Pointer<SdlAtomicT> a, int oldval, int newval) {
  final sdlAtomicCasLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<SdlAtomicT> a, Int32 oldval, Int32 newval),
      int Function(
          Pointer<SdlAtomicT> a, int oldval, int newval)>('SDL_AtomicCAS');
  return sdlAtomicCasLookupFunction(a, oldval, newval) == 1;
}