Skip to main content

SDL_TryLockMutex

Function SDL_TryLockMutex 

Source
pub unsafe extern "C" fn SDL_TryLockMutex(
    mutex: *mut SDL_Mutex,
) -> bool
Expand description

Try to lock a mutex without blocking.

This works just like SDL_LockMutex(), but if the mutex is not available, this function returns false 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 returns true if passed a NULL mutex.

§Parameters

  • mutex: the mutex to try to lock.

§Return value

Returns true on success, false if the mutex would block.

§Thread safety

It is safe to call this function from any thread.

§Availability

This function is available since SDL 3.2.0.

§See also