sdlAtomicTryLock function

bool sdlAtomicTryLock(
  1. Pointer<Int32> lock
)

Try to lock a spin lock by setting it to a non-zero value.

Please note that spinlocks are dangerous if you don't know what you're doing. Please be careful using any sort of spinlock!

\param lock a pointer to a lock variable \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held.

\since This function is available since SDL 2.0.0.

\sa SDL_AtomicLock \sa SDL_AtomicUnlock

extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock)

Implementation

bool sdlAtomicTryLock(Pointer<Int32> lock) {
  final sdlAtomicTryLockLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<Int32> lock),
      int Function(Pointer<Int32> lock)>('SDL_AtomicTryLock');
  return sdlAtomicTryLockLookupFunction(lock) == 1;
}