SDL_mutex.h File Reference
`#include "SDL_stdinc.h"`
`#include "SDL_error.h"`
`#include "begin_code.h"`
`#include "close_code.h"`
Include dependency graph for SDL_mutex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros

#define | SDL_THREAD_ANNOTATION_ATTRIBUTE__(x)
#define | SDL_CAPABILITY(x)
#define | SDL_SCOPED_CAPABILITY SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
#define | SDL_GUARDED_BY(x)
#define | SDL_PT_GUARDED_BY(x)
#define | SDL_ACQUIRED_BEFORE(x)
#define | SDL_ACQUIRED_AFTER(x)
#define | SDL_REQUIRES(x)
#define | SDL_REQUIRES_SHARED(x)
#define | SDL_ACQUIRE(x)
#define | SDL_ACQUIRE_SHARED(x)
#define | SDL_RELEASE(x)
#define | SDL_RELEASE_SHARED(x)
#define | SDL_RELEASE_GENERIC(x)
#define | SDL_TRY_ACQUIRE(x, y)
#define | SDL_TRY_ACQUIRE_SHARED(x, y)
#define | SDL_EXCLUDES(x)
#define | SDL_ASSERT_CAPABILITY(x)
#define | SDL_ASSERT_SHARED_CAPABILITY(x)
#define | SDL_RETURN_CAPABILITY(x)
#define | SDL_NO_THREAD_SAFETY_ANALYSIS SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
#define | SDL_MUTEX_TIMEDOUT 1
#define | SDL_MUTEX_MAXWAIT (~(Uint32)0)

## Mutex functions

#define | SDL_mutexP(m)
#define | SDL_mutexV(m)
typedef struct SDL_mutex | SDL_mutex
int | mutex
SDL_mutex * | SDL_CreateMutex (void)
int | SDL_LockMutex (SDL_mutex *mutex) SDL_ACQUIRE(mutex)
int | SDL_TryLockMutex (SDL_mutex *mutex) SDL_TRY_ACQUIRE(0
int | SDL_UnlockMutex (SDL_mutex *mutex) SDL_RELEASE(mutex)
void | SDL_DestroyMutex (SDL_mutex *mutex)

## Semaphore functions

typedef struct SDL_semaphore | SDL_sem
SDL_sem * | SDL_CreateSemaphore (Uint32 initial_value)
void | SDL_DestroySemaphore (SDL_sem *sem)
int | SDL_SemWait (SDL_sem *sem)
int | SDL_SemTryWait (SDL_sem *sem)
int | SDL_SemWaitTimeout (SDL_sem *sem, Uint32 timeout)
int | SDL_SemPost (SDL_sem *sem)
Uint32 | SDL_SemValue (SDL_sem *sem)

## Condition variable functions

typedef struct SDL_cond | SDL_cond
SDL_cond * | SDL_CreateCond (void)
void | SDL_DestroyCond (SDL_cond *cond)
int | SDL_CondSignal (SDL_cond *cond)
int | SDL_CondBroadcast (SDL_cond *cond)
int | SDL_CondWait (SDL_cond *cond, SDL_mutex *mutex)
int | SDL_CondWaitTimeout (SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)

## Macro Definition Documentation

## SDL_ACQUIRE

#define SDL_ACQUIRE | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x))
SDL_THREAD_ANNOTATION_ATTRIBUTE__
#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x)
Definition SDL_mutex.h:42

Definition at line 69 of file SDL_mutex.h.

#define SDL_ACQUIRE(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x))

## SDL_ACQUIRE_SHARED

#define SDL_ACQUIRE_SHARED | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x))

Definition at line 72 of file SDL_mutex.h.

#define SDL_ACQUIRE_SHARED(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x))

## SDL_ACQUIRED_AFTER

#define SDL_ACQUIRED_AFTER | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x))

Definition at line 60 of file SDL_mutex.h.

#define SDL_ACQUIRED_AFTER(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x))

## SDL_ACQUIRED_BEFORE

#define SDL_ACQUIRED_BEFORE | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x))

Definition at line 57 of file SDL_mutex.h.

#define SDL_ACQUIRED_BEFORE(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x))

## SDL_ASSERT_CAPABILITY

#define SDL_ASSERT_CAPABILITY | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))

Definition at line 93 of file SDL_mutex.h.

#define SDL_ASSERT_CAPABILITY(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))

## SDL_ASSERT_SHARED_CAPABILITY

#define SDL_ASSERT_SHARED_CAPABILITY | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))

Definition at line 96 of file SDL_mutex.h.

#define SDL_ASSERT_SHARED_CAPABILITY(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))

## SDL_CAPABILITY

#define SDL_CAPABILITY | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x))

Definition at line 45 of file SDL_mutex.h.

#define SDL_CAPABILITY(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x))

## SDL_EXCLUDES

#define SDL_EXCLUDES | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x))

Definition at line 90 of file SDL_mutex.h.

#define SDL_EXCLUDES(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x))

## SDL_GUARDED_BY

#define SDL_GUARDED_BY | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))

Definition at line 51 of file SDL_mutex.h.

#define SDL_GUARDED_BY(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))

## SDL_MUTEX_MAXWAIT

#define SDL_MUTEX_MAXWAIT (~(Uint32)0)

This is the timeout value which corresponds to never time out.

Definition at line 123 of file SDL_mutex.h.

## SDL_MUTEX_TIMEDOUT

#define SDL_MUTEX_TIMEDOUT 1

Synchronization functions which can time out return this value if they time out.

Definition at line 118 of file SDL_mutex.h.

## SDL_mutexP

#define SDL_mutexP | ( |  | m | ) |

Value:
SDL_LockMutex(m)
SDL_LockMutex
int SDL_LockMutex(SDL_mutex *mutex) SDL_ACQUIRE(mutex)

Definition at line 174 of file SDL_mutex.h.

## SDL_mutexV

#define SDL_mutexV | ( |  | m | ) |

Value:
SDL_UnlockMutex(m)
SDL_UnlockMutex
int SDL_UnlockMutex(SDL_mutex *mutex) SDL_RELEASE(mutex)

Definition at line 216 of file SDL_mutex.h.

## SDL_NO_THREAD_SAFETY_ANALYSIS

#define SDL_NO_THREAD_SAFETY_ANALYSIS SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)

Definition at line 102 of file SDL_mutex.h.

#define SDL_NO_THREAD_SAFETY_ANALYSIS \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)

## SDL_PT_GUARDED_BY

#define SDL_PT_GUARDED_BY | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))

Definition at line 54 of file SDL_mutex.h.

#define SDL_PT_GUARDED_BY(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))

## SDL_RELEASE

#define SDL_RELEASE | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x))

Definition at line 75 of file SDL_mutex.h.

#define SDL_RELEASE(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x))

## SDL_RELEASE_GENERIC

#define SDL_RELEASE_GENERIC | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x))

Definition at line 81 of file SDL_mutex.h.

#define SDL_RELEASE_GENERIC(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x))

## SDL_RELEASE_SHARED

#define SDL_RELEASE_SHARED | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x))

Definition at line 78 of file SDL_mutex.h.

#define SDL_RELEASE_SHARED(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x))

## SDL_REQUIRES

#define SDL_REQUIRES | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x))

Definition at line 63 of file SDL_mutex.h.

#define SDL_REQUIRES(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x))

## SDL_REQUIRES_SHARED

#define SDL_REQUIRES_SHARED | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x))

Definition at line 66 of file SDL_mutex.h.

#define SDL_REQUIRES_SHARED(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x))

## SDL_RETURN_CAPABILITY

#define SDL_RETURN_CAPABILITY | ( |  | x | ) |

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))

Definition at line 99 of file SDL_mutex.h.

#define SDL_RETURN_CAPABILITY(x) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))

## SDL_SCOPED_CAPABILITY

#define SDL_SCOPED_CAPABILITY SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)

Definition at line 48 of file SDL_mutex.h.

#define SDL_SCOPED_CAPABILITY \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)

## SDL_THREAD_ANNOTATION_ATTRIBUTE__

#define SDL_THREAD_ANNOTATION_ATTRIBUTE__ | ( |  | x | ) |

Value:
/* no-op */

# CategoryMutex

Functions to provide thread synchronization primitives.

Definition at line 42 of file SDL_mutex.h.

## SDL_TRY_ACQUIRE

#define SDL_TRY_ACQUIRE | ( |  | x,
|  |  | y )

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y))

Definition at line 84 of file SDL_mutex.h.

#define SDL_TRY_ACQUIRE(x, y) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y))

## SDL_TRY_ACQUIRE_SHARED

#define SDL_TRY_ACQUIRE_SHARED | ( |  | x,
|  |  | y )

Value:
SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y))

Definition at line 87 of file SDL_mutex.h.

#define SDL_TRY_ACQUIRE_SHARED(x, y) \
SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y))

## Typedef Documentation

## SDL_cond

typedef struct SDL_cond SDL_cond

Definition at line 409 of file SDL_mutex.h.

## SDL_mutex

typedef struct SDL_mutex SDL_mutex

Definition at line 133 of file SDL_mutex.h.

## SDL_sem

typedef struct SDL_semaphore SDL_sem

Definition at line 248 of file SDL_mutex.h.

## Function Documentation

## SDL_CondBroadcast()

int SDL_CondBroadcast | ( | SDL_cond * | cond | ) |

extern

Restart all threads that are waiting on the condition variable.

Parameters

  cond | the condition variable to signal.

Returns
  0 on success or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CondSignal
  SDL_CondWait
  SDL_CondWaitTimeout
  SDL_CreateCond
  SDL_DestroyCond

## SDL_CondSignal()

int SDL_CondSignal | ( | SDL_cond * | cond | ) |

extern

Restart one of the threads that are waiting on the condition variable.

Parameters

  cond | the condition variable to signal.

Returns
  0 on success or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CondBroadcast
  SDL_CondWait
  SDL_CondWaitTimeout
  SDL_CreateCond
  SDL_DestroyCond

## SDL_CondWait()

int SDL_CondWait | ( | SDL_cond * | cond,
|  | SDL_mutex * | mutex )

extern

Wait until a condition variable is signaled.

This function unlocks the specified mutex and waits for another thread to call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable cond. Once the condition variable is signaled, the mutex is re-locked and the function returns.

The mutex must be locked before calling this function.

This function is the equivalent of calling SDL_CondWaitTimeout() with a time length of SDL_MUTEX_MAXWAIT.

Parameters

  cond | the condition variable to wait on.
  mutex | the mutex used to coordinate thread access.

Returns
  0 when it is signaled or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CondBroadcast
  SDL_CondSignal
  SDL_CondWaitTimeout
  SDL_CreateCond
  SDL_DestroyCond

References mutex.

## SDL_CondWaitTimeout()

int SDL_CondWaitTimeout | ( | SDL_cond * | cond,
|  | SDL_mutex * | mutex,
|  | Uint32 | ms )

extern

Wait until a condition variable is signaled or a certain time has passed.

This function unlocks the specified mutex and waits for another thread to call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable cond, or for the specified time to elapse. Once the condition variable is signaled or the time elapsed, the mutex is re-locked and the function returns.

The mutex must be locked before calling this function.

Parameters

  cond | the condition variable to wait on.
  mutex | the mutex used to coordinate thread access.
  ms | the maximum time to wait, in milliseconds, or SDL_MUTEX_MAXWAIT to wait indefinitely.

Returns
  0 if the condition variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not signaled in the allotted time, or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CondBroadcast
  SDL_CondSignal
  SDL_CondWait
  SDL_CreateCond
  SDL_DestroyCond

References mutex.

## SDL_CreateCond()

SDL_cond * SDL_CreateCond | ( | void |  | ) |

extern

Create a condition variable.

Returns
  a new condition variable or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CondBroadcast
  SDL_CondSignal
  SDL_CondWait
  SDL_CondWaitTimeout
  SDL_DestroyCond

## SDL_CreateMutex()

SDL_mutex * SDL_CreateMutex | ( | void |  | ) |

extern

Create a new mutex.

All newly-created mutexes begin in the unlocked state.

Calls to SDL_LockMutex() will not return while the mutex is locked by another thread. See SDL_TryLockMutex() to attempt to lock without blocking.

SDL mutexes are reentrant.

Returns
  the initialized and unlocked mutex or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_DestroyMutex
  SDL_LockMutex
  SDL_TryLockMutex
  SDL_UnlockMutex

## SDL_CreateSemaphore()

SDL_sem * SDL_CreateSemaphore | ( | Uint32 | initial_value | ) |

extern

Create a semaphore.

This function creates a new semaphore and initializes it with the value initial_value. Each wait operation on the semaphore will atomically decrement the semaphore value and potentially block if the semaphore value is 0. Each post operation will atomically increment the semaphore value and wake waiting threads and allow them to retry the wait operation.

Parameters

  initial_value | the starting value of the semaphore.

Returns
  a new semaphore or NULL on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_DestroySemaphore
  SDL_SemPost
  SDL_SemTryWait
  SDL_SemValue
  SDL_SemWait
  SDL_SemWaitTimeout

## SDL_DestroyCond()

void SDL_DestroyCond | ( | SDL_cond * | cond | ) |

extern

Destroy a condition variable.

Parameters

  cond | the condition variable to destroy.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CondBroadcast
  SDL_CondSignal
  SDL_CondWait
  SDL_CondWaitTimeout
  SDL_CreateCond

## SDL_DestroyMutex()

void SDL_DestroyMutex | ( | SDL_mutex * | mutex | ) |

extern

Destroy a mutex created with SDL_CreateMutex().

This function must be called on any mutex that is no longer needed. Failure to destroy a mutex will result in a system memory or resource leak. While it is safe to destroy a mutex that is unlocked, it is not safe to attempt to destroy a locked mutex, and may result in undefined behavior depending on the platform.

Parameters

  mutex | the mutex to destroy.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateMutex
  SDL_LockMutex
  SDL_TryLockMutex
  SDL_UnlockMutex

References mutex.

## SDL_DestroySemaphore()

void SDL_DestroySemaphore | ( | SDL_sem * | sem | ) |

extern

Destroy a semaphore.

It is not safe to destroy a semaphore if there are threads currently waiting on it.

Parameters

  sem | the semaphore to destroy.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateSemaphore
  SDL_SemPost
  SDL_SemTryWait
  SDL_SemValue
  SDL_SemWait
  SDL_SemWaitTimeout

## SDL_LockMutex()

int SDL_LockMutex | ( | SDL_mutex * | mutex | ) |

extern

Lock the mutex.

This will block until the mutex is available, which is to say it is in the unlocked state and the OS has chosen the caller as the next thread to lock it. Of all threads waiting to lock the mutex, only one may do so at a time.

It is legal for the owning thread to lock an already-locked mutex. It must unlock it the same number of times before it is actually made available for other threads in the system (this is known as a "recursive mutex").

Parameters

  mutex | the mutex to lock.

Returns
  0, or -1 on error.

Since
  This function is available since SDL 2.0.0.

References mutex.

## SDL_SemPost()

int SDL_SemPost | ( | SDL_sem * | sem | ) |

extern

Atomically increment a semaphore's value and wake waiting threads.

Parameters

  sem | the semaphore to increment.

Returns
  0 on success or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateSemaphore
  SDL_DestroySemaphore
  SDL_SemTryWait
  SDL_SemValue
  SDL_SemWait
  SDL_SemWaitTimeout

## SDL_SemTryWait()

int SDL_SemTryWait | ( | SDL_sem * | sem | ) |

extern

See if a semaphore has a positive value and decrement it if it does.

This function checks to see if the semaphore pointed to by sem has a positive value and atomically decrements the semaphore value if it does. If the semaphore doesn't have a positive value, the function immediately returns SDL_MUTEX_TIMEDOUT.

Parameters

  sem | the semaphore to wait on.

Returns
  0 if the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait would block, or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateSemaphore
  SDL_DestroySemaphore
  SDL_SemPost
  SDL_SemValue
  SDL_SemWait
  SDL_SemWaitTimeout

## SDL_SemValue()

Uint32 SDL_SemValue | ( | SDL_sem * | sem | ) |

extern

Get the current value of a semaphore.

Parameters

  sem | the semaphore to query.

Returns
  the current value of the semaphore.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateSemaphore

## SDL_SemWait()

int SDL_SemWait | ( | SDL_sem * | sem | ) |

extern

Wait until a semaphore has a positive value and then decrements it.

This function suspends the calling thread until either the semaphore pointed to by sem has a positive value or the call is interrupted by a signal or error. If the call is successful it will atomically decrement the semaphore value.

This function is the equivalent of calling SDL_SemWaitTimeout() with a time length of SDL_MUTEX_MAXWAIT.

Parameters

  sem | the semaphore wait on.

Returns
  0 on success or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateSemaphore
  SDL_DestroySemaphore
  SDL_SemPost
  SDL_SemTryWait
  SDL_SemValue
  SDL_SemWait
  SDL_SemWaitTimeout

## SDL_SemWaitTimeout()

int SDL_SemWaitTimeout | ( | SDL_sem * | sem,
|  | Uint32 | timeout )

extern

Wait until a semaphore has a positive value and then decrements it.

This function suspends the calling thread until either the semaphore pointed to by sem has a positive value, the call is interrupted by a signal or error, or the specified time has elapsed. If the call is successful it will atomically decrement the semaphore value.

Parameters

  sem | the semaphore to wait on.
  timeout | the length of the timeout, in milliseconds.

Returns
  0 if the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in the allotted time, or a negative error code on failure; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateSemaphore
  SDL_DestroySemaphore
  SDL_SemPost
  SDL_SemTryWait
  SDL_SemValue
  SDL_SemWait

## SDL_TryLockMutex()

int SDL_TryLockMutex | ( | SDL_mutex * | mutex | ) |

extern

Try to lock a mutex without blocking.

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

Parameters

  mutex | the mutex to try to lock.

Returns
  0, SDL_MUTEX_TIMEDOUT, or -1 on error; call SDL_GetError() for more information.

Since
  This function is available since SDL 2.0.0.

See also
  SDL_CreateMutex
  SDL_DestroyMutex
  SDL_LockMutex
  SDL_UnlockMutex

## SDL_UnlockMutex()

int SDL_UnlockMutex | ( | SDL_mutex * | mutex | ) |

extern

Unlock the mutex.

It is legal for the owning thread to lock an already-locked mutex. It must unlock it the same number of times before it is actually made available for other threads in the system (this is known as a "recursive mutex").

It is an error to unlock a mutex that has not been locked by the current thread, and doing so results in undefined behavior.

It is also an error to unlock a mutex that isn't locked at all.

Parameters

  mutex | the mutex to unlock.

Returns
  0, or -1 on error.

Since
  This function is available since SDL 2.0.0.

References mutex.

## Variable Documentation

## mutex

int mutex

Definition at line 196 of file SDL_mutex.h.

Referenced by SDL_CondWait(), SDL_CondWaitTimeout(), SDL_DestroyMutex(), SDL_LockMutex(), and SDL_UnlockMutex().