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.

Parameter: mutex the mutex to try to lock. Returns: true on success, false if the mutex would block.

Thread Safety: It is safe to call this function from any thread.

Available Since: This function is available since SDL 3.2.0.

See Also: SDL_LockMutex See Also: SDL_UnlockMutex