---
name: "SDL_TryLockSpinlock"
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_TryLockSpinlock"
---

# SDL\_TryLockSpinlock(3)

Try to lock a spin lock by setting it to a non-zero value.

## NAME

SDL\_TryLockSpinlock - Try to lock a spin lock by setting it to a non-zero value.

## HEADER FILE

Defined in SDL3/SDL\_atomic.h

## SYNOPSIS

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

**bool SDL\_TryLockSpinlock(SDL\_SpinLock \*lock);**

## DESCRIPTION

**Please note that spinlocks are dangerous if you don't know what you're** doing. Please be careful using any sort of spinlock!

## FUNCTION PARAMETERS

- *lock*

  a pointer to a lock variable.

## RETURN VALUE

Returns true if the lock succeeded, false if the lock is already held.

## THREAD SAFETY

It is safe to call this function from any thread.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_LockSpinlock**(3)](/SDL_LockSpinlock/3.md), **•**(3), [**SDL\_UnlockSpinlock**(3)](/SDL_UnlockSpinlock/3.md)
