sdlTryLockMutex function

int sdlTryLockMutex(
  1. Pointer<NativeType> arg0,
  2. Pointer<NativeType> arg1
)

Try to lock a mutex without blocking.

This works just like SDL_LockMutex(), but if the mutex is not available, this function returns SDL_MUTEX_TIMEOUT immediately.

This technique is useful if you need exclusive access to a resource but don't want to wait for it, and will return to it to try again later.

\param mutex the mutex to try to lock \returns 0, SDL_MUTEX_TIMEDOUT, or -1 on error; call SDL_GetError() for more information.

\since This function is available since SDL 2.0.0.

\sa SDL_CreateMutex \sa SDL_DestroyMutex \sa SDL_LockMutex \sa SDL_UnlockMutex

extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex) SDL_TRY_ACQUIRE(0, mutex)

Implementation

int sdlTryLockMutex(Pointer<NativeType> arg0, Pointer<NativeType> arg1) {
  final sdlTryLockMutexLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<NativeType> arg0, Pointer<NativeType> arg1),
      int Function(Pointer<NativeType> arg0,
          Pointer<NativeType> arg1)>('SDL_TryLockMutex');
  return sdlTryLockMutexLookupFunction(arg0, arg1);
}