Scroll to navigation

SDL_TryLockMutex(3) SDL3 FUNCTIONS SDL_TryLockMutex(3)

NAME

SDL_TryLockMutex - Try to lock a mutex without blocking.

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

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)

SDL 3.1.0 SDL