thread topic

CategoryThread

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.

Functions

sdlCleanupTls() → void thread
Cleanup all TLS data for this thread.
sdlCreateThread(Pointer<NativeFunction<SdlThreadFunction>> fn, String? name, Pointer<NativeType> data) Pointer<SdlThread> thread
Create a new thread with a default stack size.
sdlCreateThreadRuntime(Pointer<NativeFunction<SdlThreadFunction>> fn, String? name, Pointer<NativeType> data, Pointer<NativeType> pfnBeginThread, Pointer<NativeType> pfnEndThread) Pointer<SdlThread> thread
The actual entry point for SDL_CreateThread.
sdlCreateThreadWithProperties(int props) Pointer<SdlThread> thread
Create a new thread with with the specified properties.
sdlCreateThreadWithPropertiesRuntime(int props, Pointer<NativeType> pfnBeginThread, Pointer<NativeType> pfnEndThread) Pointer<SdlThread> thread
The actual entry point for SDL_CreateThreadWithProperties.
sdlDetachThread(Pointer<SdlThread> thread) → void thread
Let a thread clean up on exit without intervention.
sdlGetCurrentThreadId() int thread
Get the thread identifier for the current thread.
sdlGetThreadId(Pointer<SdlThread> thread) int thread
Get the thread identifier for the specified thread.
sdlGetThreadName(Pointer<SdlThread> thread) String? thread
Get the thread name as it was specified in SDL_CreateThread().
sdlGetThreadState(Pointer<SdlThread> thread) int thread
Get the current state of a thread.
sdlGetTls(Pointer<SdlAtomicInt> id) Pointer<NativeType> thread
Get the current thread's value associated with a thread local storage ID.
sdlSetCurrentThreadPriority(int priority) bool thread
Set the priority for the current thread.
sdlSetTls(Pointer<SdlAtomicInt> id, Pointer<NativeType> value, Pointer<NativeType> deor) bool thread
Set the current thread's value associated with a thread local storage ID.
sdlWaitThread(Pointer<SdlThread> thread, Pointer<Int32> status) → void thread
Wait for a thread to finish.