Function SDL_TryLockMutex

pub unsafe extern "C" fn SDL_TryLockMutex(
    mutex: *mut SDL_Mutex,
) -> bool
Available on crate feature dep_sdl3 only.
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.

§Availability

This function is available since SDL 3.2.0.

§See also