sdlSemTryWait function

int sdlSemTryWait(
  1. Pointer<SdlSem> sem
)

See if a semaphore has a positive value and decrement it if it does.

This function checks to see if the semaphore pointed to by sem has a positive value and atomically decrements the semaphore value if it does. If the semaphore doesn't have a positive value, the function immediately returns SDL_MUTEX_TIMEDOUT.

\param sem the semaphore to wait on \returns 0 if the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait would block, or a negative error code on failure; call SDL_GetError() for more information.

\since This function is available since SDL 2.0.0.

\sa SDL_CreateSemaphore \sa SDL_DestroySemaphore \sa SDL_SemPost \sa SDL_SemValue \sa SDL_SemWait \sa SDL_SemWaitTimeout

extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem)

Implementation

int sdlSemTryWait(Pointer<SdlSem> sem) {
  final sdlSemTryWaitLookupFunction = libSdl2.lookupFunction<
      Int32 Function(Pointer<SdlSem> sem),
      int Function(Pointer<SdlSem> sem)>('SDL_SemTryWait');
  return sdlSemTryWaitLookupFunction(sem);
}