Module mutex

Available on crate feature dep_sdl3 only.
Expand description

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.

SDL also offers a datatype, 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.

Structs§

SDL_Condition
A means to block multiple threads until a condition is satisfied.
SDL_InitState
A structure used for thread-safe initialization and shutdown.
SDL_InitStatus
The current status of an SDL_InitState structure.
SDL_Mutex
A means to serialize access to a resource between threads.
SDL_RWLock
A mutex that allows read-only threads to run in parallel.
SDL_Semaphore
A means to manage access to a resource, by count, between threads.

Constants§

SDL_INIT_STATUS_INITIALIZED
SDL_INIT_STATUS_INITIALIZING
SDL_INIT_STATUS_UNINITIALIZED
SDL_INIT_STATUS_UNINITIALIZING

Functions§

SDL_BroadcastCondition
Restart all threads that are waiting on the condition variable.
SDL_CreateCondition
Create a condition variable.
SDL_CreateMutex
Create a new mutex.
SDL_CreateRWLock
Create a new read/write lock.
SDL_CreateSemaphore
Create a semaphore.
SDL_DestroyCondition
Destroy a condition variable.
SDL_DestroyMutex
Destroy a mutex created with SDL_CreateMutex().
SDL_DestroyRWLock
Destroy a read/write lock created with SDL_CreateRWLock().
SDL_DestroySemaphore
Destroy a semaphore.
SDL_GetSemaphoreValue
Get the current value of a semaphore.
SDL_LockMutex
Lock the mutex.
SDL_LockRWLockForReading
Lock the read/write lock for read only operations.
SDL_LockRWLockForWriting
Lock the read/write lock for write operations.
SDL_SetInitialized
Finish an initialization state transition.
SDL_ShouldInit
Return whether initialization should be done.
SDL_ShouldQuit
Return whether cleanup should be done.
SDL_SignalCondition
Restart one of the threads that are waiting on the condition variable.
SDL_SignalSemaphore
Atomically increment a semaphore’s value and wake waiting threads.
SDL_TryLockMutex
Try to lock a mutex without blocking.
SDL_TryLockRWLockForReading
Try to lock a read/write lock for reading without blocking.
SDL_TryLockRWLockForWriting
Try to lock a read/write lock for writing without blocking.
SDL_TryWaitSemaphore
See if a semaphore has a positive value and decrement it if it does.
SDL_UnlockMutex
Unlock the mutex.
SDL_UnlockRWLock
Unlock the read/write lock.
SDL_WaitCondition
Wait until a condition variable is signaled.
SDL_WaitConditionTimeout
Wait until a condition variable is signaled or a certain time has passed.
SDL_WaitSemaphore
Wait until a semaphore has a positive value and then decrements it.
SDL_WaitSemaphoreTimeout
Wait until a semaphore has a positive value and then decrements it.