# CategoryMutex

SDL offers several thread synchronization primitives. This document can't
cover the complicated topic of thread safety, but reading up on what each
of these primitives are, why they are useful, and how to correctly use them
is vital to writing correct and safe multithreaded programs.

- Mutexes: [SDL_CreateMutex](SDL_CreateMutex)()
- Read/Write locks: [SDL_CreateRWLock](SDL_CreateRWLock)()
- Semaphores: [SDL_CreateSemaphore](SDL_CreateSemaphore)()
- Condition variables: [SDL_CreateCondition](SDL_CreateCondition)()

SDL also offers a datatype, [SDL_InitState](SDL_InitState), which can be
used to make sure only one thread initializes/deinitializes some resource
that several threads might try to use for the first time simultaneously.

<!-- END CATEGORY DOCUMENTATION -->

## Functions

<!-- DO NOT HAND-EDIT CATEGORY LISTS, THEY ARE AUTOGENERATED AND WILL BE OVERWRITTEN, BASED ON TAGS IN INDIVIDUAL PAGE FOOTERS. EDIT THOSE INSTEAD. -->
<!-- BEGIN CATEGORY LIST: CategoryMutex, CategoryAPIFunction -->
- [SDL_BroadcastCondition](SDL_BroadcastCondition)
- [SDL_CreateCondition](SDL_CreateCondition)
- [SDL_CreateMutex](SDL_CreateMutex)
- [SDL_CreateRWLock](SDL_CreateRWLock)
- [SDL_CreateSemaphore](SDL_CreateSemaphore)
- [SDL_DestroyCondition](SDL_DestroyCondition)
- [SDL_DestroyMutex](SDL_DestroyMutex)
- [SDL_DestroyRWLock](SDL_DestroyRWLock)
- [SDL_DestroySemaphore](SDL_DestroySemaphore)
- [SDL_GetSemaphoreValue](SDL_GetSemaphoreValue)
- [SDL_LockMutex](SDL_LockMutex)
- [SDL_LockRWLockForReading](SDL_LockRWLockForReading)
- [SDL_LockRWLockForWriting](SDL_LockRWLockForWriting)
- [SDL_SetInitialized](SDL_SetInitialized)
- [SDL_ShouldInit](SDL_ShouldInit)
- [SDL_ShouldQuit](SDL_ShouldQuit)
- [SDL_SignalCondition](SDL_SignalCondition)
- [SDL_SignalSemaphore](SDL_SignalSemaphore)
- [SDL_TryLockMutex](SDL_TryLockMutex)
- [SDL_TryLockRWLockForReading](SDL_TryLockRWLockForReading)
- [SDL_TryLockRWLockForWriting](SDL_TryLockRWLockForWriting)
- [SDL_TryWaitSemaphore](SDL_TryWaitSemaphore)
- [SDL_UnlockMutex](SDL_UnlockMutex)
- [SDL_UnlockRWLock](SDL_UnlockRWLock)
- [SDL_WaitCondition](SDL_WaitCondition)
- [SDL_WaitConditionTimeout](SDL_WaitConditionTimeout)
- [SDL_WaitSemaphore](SDL_WaitSemaphore)
- [SDL_WaitSemaphoreTimeout](SDL_WaitSemaphoreTimeout)
<!-- END CATEGORY LIST -->

## Datatypes

<!-- DO NOT HAND-EDIT CATEGORY LISTS, THEY ARE AUTOGENERATED AND WILL BE OVERWRITTEN, BASED ON TAGS IN INDIVIDUAL PAGE FOOTERS. EDIT THOSE INSTEAD. -->
<!-- BEGIN CATEGORY LIST: CategoryMutex, CategoryAPIDatatype -->
- [SDL_Condition](SDL_Condition)
- [SDL_Mutex](SDL_Mutex)
- [SDL_RWLock](SDL_RWLock)
- [SDL_Semaphore](SDL_Semaphore)
<!-- END CATEGORY LIST -->

## Structs

<!-- DO NOT HAND-EDIT CATEGORY LISTS, THEY ARE AUTOGENERATED AND WILL BE OVERWRITTEN, BASED ON TAGS IN INDIVIDUAL PAGE FOOTERS. EDIT THOSE INSTEAD. -->
<!-- BEGIN CATEGORY LIST: CategoryMutex, CategoryAPIStruct -->
- [SDL_InitState](SDL_InitState)
<!-- END CATEGORY LIST -->

## Enums

<!-- DO NOT HAND-EDIT CATEGORY LISTS, THEY ARE AUTOGENERATED AND WILL BE OVERWRITTEN, BASED ON TAGS IN INDIVIDUAL PAGE FOOTERS. EDIT THOSE INSTEAD. -->
<!-- BEGIN CATEGORY LIST: CategoryMutex, CategoryAPIEnum -->
- [SDL_InitStatus](SDL_InitStatus)
<!-- END CATEGORY LIST -->

## Macros

<!-- DO NOT HAND-EDIT CATEGORY LISTS, THEY ARE AUTOGENERATED AND WILL BE OVERWRITTEN, BASED ON TAGS IN INDIVIDUAL PAGE FOOTERS. EDIT THOSE INSTEAD. -->
<!-- BEGIN CATEGORY LIST: CategoryMutex, CategoryAPIMacro -->
- [SDL_ACQUIRE](SDL_ACQUIRE)
- [SDL_ACQUIRE_SHARED](SDL_ACQUIRE_SHARED)
- [SDL_ACQUIRED_AFTER](SDL_ACQUIRED_AFTER)
- [SDL_ACQUIRED_BEFORE](SDL_ACQUIRED_BEFORE)
- [SDL_ASSERT_CAPABILITY](SDL_ASSERT_CAPABILITY)
- [SDL_ASSERT_SHARED_CAPABILITY](SDL_ASSERT_SHARED_CAPABILITY)
- [SDL_CAPABILITY](SDL_CAPABILITY)
- [SDL_EXCLUDES](SDL_EXCLUDES)
- [SDL_GUARDED_BY](SDL_GUARDED_BY)
- [SDL_NO_THREAD_SAFETY_ANALYSIS](SDL_NO_THREAD_SAFETY_ANALYSIS)
- [SDL_PT_GUARDED_BY](SDL_PT_GUARDED_BY)
- [SDL_RELEASE](SDL_RELEASE)
- [SDL_RELEASE_GENERIC](SDL_RELEASE_GENERIC)
- [SDL_RELEASE_SHARED](SDL_RELEASE_SHARED)
- [SDL_REQUIRES](SDL_REQUIRES)
- [SDL_REQUIRES_SHARED](SDL_REQUIRES_SHARED)
- [SDL_RETURN_CAPABILITY](SDL_RETURN_CAPABILITY)
- [SDL_SCOPED_CAPABILITY](SDL_SCOPED_CAPABILITY)
- [SDL_THREAD_ANNOTATION_ATTRIBUTE__](SDL_THREAD_ANNOTATION_ATTRIBUTE__)
- [SDL_TRY_ACQUIRE](SDL_TRY_ACQUIRE)
- [SDL_TRY_ACQUIRE_SHARED](SDL_TRY_ACQUIRE_SHARED)
<!-- END CATEGORY LIST -->


----
[CategoryAPICategory](CategoryAPICategory)

