Module thread
Available on crate feature
dep_sdl3
only.Expand description
SDL offers cross-platform thread management functions. These are mostly concerned with starting threads, setting their priority, and dealing with their termination.
In addition, there is support for Thread Local Storage (data that is unique to each thread, but accessed from a single key).
On platforms without thread support (such as Emscripten when built without
pthreads), these functions still exist, but things like SDL_CreateThread()
will report failure without doing anything.
If you’re going to work with threads, you almost certainly need to have a good understanding of CategoryMutex as well.
Structs§
- SDL_
Thread - The SDL thread object.
- SDL_
Thread Priority - The SDL thread priority.
- SDL_
Thread State - The SDL thread state.
Constants§
- SDL_
Begin Thread Function - SDL_
EndThread Function - SDL_
PROP_ THREAD_ CREATE_ ENTRY_ FUNCTION_ POINTER - SDL_
PROP_ THREAD_ CREATE_ NAME_ STRING - SDL_
PROP_ THREAD_ CREATE_ STACKSIZE_ NUMBER - SDL_
PROP_ THREAD_ CREATE_ USERDATA_ POINTER - SDL_
THREAD_ ALIVE - The thread is currently running
- SDL_
THREAD_ COMPLETE - The thread has finished and should be cleaned up with
SDL_WaitThread()
- SDL_
THREAD_ DETACHED - The thread is detached and can’t be waited on
- SDL_
THREAD_ PRIORITY_ HIGH - SDL_
THREAD_ PRIORITY_ LOW - SDL_
THREAD_ PRIORITY_ NORMAL - SDL_
THREAD_ PRIORITY_ TIME_ CRITICAL - SDL_
THREAD_ UNKNOWN - The thread is not valid
Functions§
- SDL_
CleanupTLS ⚠ - Cleanup all TLS data for this thread.
- SDL_
Create ⚠Thread - SDL_
Create ⚠Thread Runtime - The actual entry point for
SDL_CreateThread
. - SDL_
Create ⚠Thread With Properties - SDL_
Create ⚠Thread With Properties Runtime - The actual entry point for
SDL_CreateThreadWithProperties
. - SDL_
Detach ⚠Thread - Let a thread clean up on exit without intervention.
- SDL_
GetCurrent ⚠ThreadID - Get the thread identifier for the current thread.
- SDL_
GetTLS ⚠ - Get the current thread’s value associated with a thread local storage ID.
- SDL_
GetThreadID ⚠ - Get the thread identifier for the specified thread.
- SDL_
GetThread ⚠Name - Get the thread name as it was specified in
SDL_CreateThread()
. - SDL_
GetThread ⚠State - Get the current state of a thread.
- SDL_
SetCurrent ⚠Thread Priority - Set the priority for the current thread.
- SDL_
SetTLS ⚠ - Set the current thread’s value associated with a thread local storage ID.
- SDL_
Wait ⚠Thread - Wait for a thread to finish.
Type Aliases§
- SDL_
TLSDestructor Callback - The callback used to cleanup data passed to
SDL_SetTLS
. - SDL_
TLSID - Thread local storage ID.
- SDL_
Thread Function - The function passed to
SDL_CreateThread()
as the new thread’s entry point. - SDL_
ThreadID - A unique numeric ID that identifies a thread.