sdlTryLockSpinlock function

bool sdlTryLockSpinlock(
  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 true if the lock succeeded, false if the lock is already held.

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

\since This function is available since SDL 3.1.3.

\sa SDL_LockSpinlock \sa SDL_UnlockSpinlock

extern SDL_DECLSPEC bool SDLCALL SDL_TryLockSpinlock(SDL_SpinLock *lock)

Implementation

bool sdlTryLockSpinlock(Pointer<Int32> lock) {
  final sdlTryLockSpinlockLookupFunction = libSdl3.lookupFunction<
      Uint8 Function(Pointer<Int32> lock),
      int Function(Pointer<Int32> lock)>('SDL_TryLockSpinlock');
  return sdlTryLockSpinlockLookupFunction(lock) == 1;
}