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_ThreadPriority
The SDL thread priority.
SDL_ThreadState
The SDL thread state.

Constants§

SDL_BeginThreadFunction
SDL_EndThreadFunction
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_CreateThread
SDL_CreateThreadRuntime
The actual entry point for SDL_CreateThread.
SDL_CreateThreadWithProperties
SDL_CreateThreadWithPropertiesRuntime
The actual entry point for SDL_CreateThreadWithProperties.
SDL_DetachThread
Let a thread clean up on exit without intervention.
SDL_GetCurrentThreadID
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_GetThreadName
Get the thread name as it was specified in SDL_CreateThread().
SDL_GetThreadState
Get the current state of a thread.
SDL_SetCurrentThreadPriority
Set the priority for the current thread.
SDL_SetTLS
Set the current thread’s value associated with a thread local storage ID.
SDL_WaitThread
Wait for a thread to finish.

Type Aliases§

SDL_TLSDestructorCallback
The callback used to cleanup data passed to SDL_SetTLS.
SDL_TLSID
Thread local storage ID.
SDL_ThreadFunction
The function passed to SDL_CreateThread() as the new thread’s entry point.
SDL_ThreadID
A unique numeric ID that identifies a thread.