---
name: "SDL_TryLockMutex"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_TryLockMutex"
---

# SDL\_TryLockMutex(3)

Try to lock a mutex without blocking.

## NAME

SDL\_TryLockMutex - Try to lock a mutex without blocking.

## HEADER FILE

Defined in SDL3/SDL\_mutex.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_TryLockMutex(SDL\_Mutex \*mutex);**

## DESCRIPTION

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.

## FUNCTION 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

**•**(3), [**SDL\_LockMutex**(3)](/SDL_LockMutex/3.md), **•**(3), [**SDL\_UnlockMutex**(3)](/SDL_UnlockMutex/3.md)
