SDL_TryLockMutex(3)

NAME
SDL_TryLockMutex - Try to lock a mutex without blocking.

HEADER FILE
Defined in SDL3/SDL_mutex.h

SYNOPSIS
#include "SDL3/SDL.h"

int SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0, mutex);

DESCRIPTION
This works just like SDL_LockMutex (), but if the mutex is not available, this function returns SDL_MUTEX_TIMEDOUT 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. This function does not fail; if mutex is NULL, it will return 0 immediately having locked nothing. If the mutex is valid, this function will always either lock the mutex and return 0, or return SDL_MUTEX_TIMEOUT
 and lock nothing.

FUNCTION PARAMETERS

mutex
    the mutex to try to lock

RETURN VALUE
Returns 0 or SDL_MUTEX_TIMEDOUT

AVAILABILITY
This function is available since SDL 3.0.0.

SEE ALSO
SDL_LockMutex(3), SDL_UnlockMutex(3)