sdl3-bindgen-sys
Safe HaskellNone
LanguageGHC2021

SDL3.Sys.Thread

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 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 thread safety measures: locking and synchronization mechanisms are handled by the functions in SDL_mutex.h. The SDL thread object.

These are opaque data.

See also
createThread, waitThread

FFI conventions

Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Thread.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.

The C shims are functions this package defines in C over what the FFI cannot call directly (variadic functions, function-like macros), each named after what it wraps; the same flavor rules apply. Their raw imports live under SDL3.Sys.Bindgen.ThreadShims.

Full conventions: SDL3.Sys.

Since: 3.2.0

Synopsis

Documentation

Function aliases

createThreadRuntime Source #

Arguments

:: SDL_ThreadFunction
fn
the SDL_ThreadFunction function to call in the new thread
-> PtrConst CChar
name
the name of the thread
-> Ptr Void
data
a pointer that is passed to fn
-> SDL_FunctionPointer
pfnBeginThread
the C runtime's _beginthreadex (or whatnot). Can be NULL.
-> SDL_FunctionPointer
pfnEndThread
the C runtime's _endthreadex (or whatnot). Can be NULL.
-> IO (Ptr SDL_Thread) 

The actual entry point for createThread.

Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CreateThreadRuntime. The safe flavor is createThreadRuntimeSafe : the entry function runs on the spawned thread, not during the call.
C declaration
SDL_CreateThreadRuntime, defined at SDL3/SDL_thread.h 340:42

Since: 3.2.0

createThreadRuntimeSafe Source #

Arguments

:: SDL_ThreadFunction
fn
the SDL_ThreadFunction function to call in the new thread
-> PtrConst CChar
name
the name of the thread
-> Ptr Void
data
a pointer that is passed to fn
-> SDL_FunctionPointer
pfnBeginThread
the C runtime's _beginthreadex (or whatnot). Can be NULL.
-> SDL_FunctionPointer
pfnEndThread
the C runtime's _endthreadex (or whatnot). Can be NULL.
-> IO (Ptr SDL_Thread) 

The actual entry point for createThread.

Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CreateThreadRuntime. The unsafe flavor is createThreadRuntime : the entry function runs on the spawned thread, not during the call.
C declaration
SDL_CreateThreadRuntime, defined at SDL3/SDL_thread.h 340:42

Since: 3.2.0

createThreadWithPropertiesRuntime Source #

Arguments

:: SDL_PropertiesID
props
the properties to use
-> SDL_FunctionPointer
pfnBeginThread
the C runtime's _beginthreadex (or whatnot). Can be NULL.
-> SDL_FunctionPointer
pfnEndThread
the C runtime's _endthreadex (or whatnot). Can be NULL.
-> IO (Ptr SDL_Thread) 

The actual entry point for createThreadWithProperties.

Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CreateThreadWithPropertiesRuntime. The safe flavor is createThreadWithPropertiesRuntimeSafe : the entry function runs on the spawned thread, not during the call.
C declaration
SDL_CreateThreadWithPropertiesRuntime, defined at SDL3/SDL_thread.h 356:42

Since: 3.2.0

createThreadWithPropertiesRuntimeSafe Source #

Arguments

:: SDL_PropertiesID
props
the properties to use
-> SDL_FunctionPointer
pfnBeginThread
the C runtime's _beginthreadex (or whatnot). Can be NULL.
-> SDL_FunctionPointer
pfnEndThread
the C runtime's _endthreadex (or whatnot). Can be NULL.
-> IO (Ptr SDL_Thread) 

The actual entry point for createThreadWithProperties.

Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CreateThreadWithPropertiesRuntime. The unsafe flavor is createThreadWithPropertiesRuntime : the entry function runs on the spawned thread, not during the call.
C declaration
SDL_CreateThreadWithPropertiesRuntime, defined at SDL3/SDL_thread.h 356:42

Since: 3.2.0

getThreadName Source #

Arguments

:: Ptr SDL_Thread
thread
the thread to query.
-> IO (PtrConst CChar) 

Get the thread name as it was specified in createThread.

Returns
a pointer to a UTF-8 string that names the specified thread, or NULL if it doesn't have a name.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetThreadName. The safe flavor is getThreadNameSafe .
C declaration
SDL_GetThreadName, defined at SDL3/SDL_thread.h 378:42

Since: 3.2.0

getThreadNameSafe Source #

Arguments

:: Ptr SDL_Thread
thread
the thread to query.
-> IO (PtrConst CChar) 

Get the thread name as it was specified in createThread.

Returns
a pointer to a UTF-8 string that names the specified thread, or NULL if it doesn't have a name.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetThreadName. The unsafe flavor is getThreadName .
C declaration
SDL_GetThreadName, defined at SDL3/SDL_thread.h 378:42

Since: 3.2.0

getCurrentThreadID :: IO SDL_ThreadID Source #

Get the thread identifier for the current thread.

This thread identifier is as reported by the underlying operating system. If SDL is running on a platform that does not support threads the return value will always be zero.

This function also returns a valid thread ID when called from the main thread.

Returns
the ID of the current thread.
Thread safety
It is safe to call this function from any thread.
See also
getThreadID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetCurrentThreadID. The safe flavor is getCurrentThreadIDSafe .
C declaration
SDL_GetCurrentThreadID, defined at SDL3/SDL_thread.h 398:42

Since: 3.2.0

getCurrentThreadIDSafe :: IO SDL_ThreadID Source #

Get the thread identifier for the current thread.

This thread identifier is as reported by the underlying operating system. If SDL is running on a platform that does not support threads the return value will always be zero.

This function also returns a valid thread ID when called from the main thread.

Returns
the ID of the current thread.
Thread safety
It is safe to call this function from any thread.
See also
getThreadID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetCurrentThreadID. The unsafe flavor is getCurrentThreadID .
C declaration
SDL_GetCurrentThreadID, defined at SDL3/SDL_thread.h 398:42

Since: 3.2.0

getThreadID Source #

Arguments

:: Ptr SDL_Thread
thread
the thread to query.
-> IO SDL_ThreadID 

Get the thread identifier for the specified thread.

This thread identifier is as reported by the underlying operating system. If SDL is running on a platform that does not support threads the return value will always be zero.

Returns
the ID of the specified thread, or the ID of the current thread if thread is NULL.
Thread safety
It is safe to call this function from any thread.
See also
getCurrentThreadID

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetThreadID. The safe flavor is getThreadIDSafe .
C declaration
SDL_GetThreadID, defined at SDL3/SDL_thread.h 417:42

Since: 3.2.0

getThreadIDSafe Source #

Arguments

:: Ptr SDL_Thread
thread
the thread to query.
-> IO SDL_ThreadID 

Get the thread identifier for the specified thread.

This thread identifier is as reported by the underlying operating system. If SDL is running on a platform that does not support threads the return value will always be zero.

Returns
the ID of the specified thread, or the ID of the current thread if thread is NULL.
Thread safety
It is safe to call this function from any thread.
See also
getCurrentThreadID

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetThreadID. The unsafe flavor is getThreadID .
C declaration
SDL_GetThreadID, defined at SDL3/SDL_thread.h 417:42

Since: 3.2.0

setCurrentThreadPriority Source #

Arguments

:: SDL_ThreadPriority
priority
the SDL_ThreadPriority to set.
-> IO Bool 

Set the priority for the current thread.

Note that some platforms will not let you alter the priority (or at least, promote the thread to a higher priority) at all, and some require you to be an administrator account. Be prepared for this to fail.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetCurrentThreadPriority. The safe flavor is setCurrentThreadPrioritySafe .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetCurrentThreadPriority, defined at SDL3/SDL_thread.h 434:34

Since: 3.2.0

setCurrentThreadPrioritySafe Source #

Arguments

:: SDL_ThreadPriority
priority
the SDL_ThreadPriority to set.
-> IO Bool 

Set the priority for the current thread.

Note that some platforms will not let you alter the priority (or at least, promote the thread to a higher priority) at all, and some require you to be an administrator account. Be prepared for this to fail.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetCurrentThreadPriority. The unsafe flavor is setCurrentThreadPriority .
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetCurrentThreadPriority, defined at SDL3/SDL_thread.h 434:34

Since: 3.2.0

waitThread Source #

Arguments

:: Ptr SDL_Thread
thread
the SDL_Thread pointer that was returned from the createThread call that started this thread.
-> Ptr CInt
status
a pointer filled in with the value returned from the thread function by its 'return', or -1 if the thread has been detached or isn't valid, may be NULL.
-> IO () 

Wait for a thread to finish.

Threads that haven't been detached will remain until this function cleans them up. Not doing so is a resource leak.

Once a thread has been cleaned up through this function, the SDL_Thread that references it becomes invalid and should not be referenced again. As such, only one thread may call waitThread on another.

The return code from the thread function is placed in the area pointed to by status, if status is not NULL.

You may not wait on a thread that has been used in a call to detachThread. Use either that function or this one, but not both, or behavior is undefined.

It is safe to pass a NULL thread to this function; it is a no-op.

Note that the thread pointer is freed by this function and is not valid afterward.

Thread safety
It is safe to call this function from any thread, but only a single thread can wait any specific thread to finish.
See also
createThread, detachThread

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_WaitThread. The safe flavor is waitThreadSafe : blocks until the thread exits.
C declaration
SDL_WaitThread, defined at SDL3/SDL_thread.h 472:34

Since: 3.2.0

waitThreadSafe Source #

Arguments

:: Ptr SDL_Thread
thread
the SDL_Thread pointer that was returned from the createThread call that started this thread.
-> Ptr CInt
status
a pointer filled in with the value returned from the thread function by its 'return', or -1 if the thread has been detached or isn't valid, may be NULL.
-> IO () 

Wait for a thread to finish.

Threads that haven't been detached will remain until this function cleans them up. Not doing so is a resource leak.

Once a thread has been cleaned up through this function, the SDL_Thread that references it becomes invalid and should not be referenced again. As such, only one thread may call waitThread on another.

The return code from the thread function is placed in the area pointed to by status, if status is not NULL.

You may not wait on a thread that has been used in a call to detachThread. Use either that function or this one, but not both, or behavior is undefined.

It is safe to pass a NULL thread to this function; it is a no-op.

Note that the thread pointer is freed by this function and is not valid afterward.

Thread safety
It is safe to call this function from any thread, but only a single thread can wait any specific thread to finish.
See also
createThread, detachThread

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_WaitThread. The unsafe flavor is waitThread : blocks until the thread exits.
C declaration
SDL_WaitThread, defined at SDL3/SDL_thread.h 472:34

Since: 3.2.0

getThreadState Source #

Arguments

:: Ptr SDL_Thread
thread
the thread to query.
-> IO SDL_ThreadState 

Get the current state of a thread.

Returns
the current state of a thread, or SDL_THREAD_UNKNOWN if the thread isn't valid.
Thread safety
It is safe to call this function from any thread.
See also
SDL_ThreadState

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetThreadState. The safe flavor is getThreadStateSafe .
C declaration
SDL_GetThreadState, defined at SDL3/SDL_thread.h 487:45

Since: 3.2.0

getThreadStateSafe Source #

Arguments

:: Ptr SDL_Thread
thread
the thread to query.
-> IO SDL_ThreadState 

Get the current state of a thread.

Returns
the current state of a thread, or SDL_THREAD_UNKNOWN if the thread isn't valid.
Thread safety
It is safe to call this function from any thread.
See also
SDL_ThreadState

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetThreadState. The unsafe flavor is getThreadState .
C declaration
SDL_GetThreadState, defined at SDL3/SDL_thread.h 487:45

Since: 3.2.0

detachThread Source #

Arguments

:: Ptr SDL_Thread
thread
the SDL_Thread pointer that was returned from the createThread call that started this thread.
-> IO () 

Let a thread clean up on exit without intervention.

A thread may be "detached" to signify that it should not remain until another thread has called waitThread on it. Detaching a thread is useful for long-running threads that nothing needs to synchronize with or further manage. When a detached thread is done, it simply goes away.

There is no way to recover the return code of a detached thread. If you need this, don't detach the thread and instead use waitThread.

Once a thread is detached, you should usually assume the SDL_Thread isn't safe to reference again, as it will become invalid immediately upon the detached thread's exit, instead of remaining until someone has called waitThread to finally clean it up. As such, don't detach the same thread more than once.

If a thread has already exited when passed to detachThread, it will stop waiting for a call to waitThread and clean up immediately. It is not safe to detach a thread that might be used with waitThread.

You may not call waitThread on a thread that has been detached. Use either that function or this one, but not both, or behavior is undefined.

It is safe to pass NULL to this function; it is a no-op.

Thread safety
It is safe to call this function from any thread.
See also
createThread, waitThread

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_DetachThread. The safe flavor is detachThreadSafe .
C declaration
SDL_DetachThread, defined at SDL3/SDL_thread.h 525:34

Since: 3.2.0

detachThreadSafe Source #

Arguments

:: Ptr SDL_Thread
thread
the SDL_Thread pointer that was returned from the createThread call that started this thread.
-> IO () 

Let a thread clean up on exit without intervention.

A thread may be "detached" to signify that it should not remain until another thread has called waitThread on it. Detaching a thread is useful for long-running threads that nothing needs to synchronize with or further manage. When a detached thread is done, it simply goes away.

There is no way to recover the return code of a detached thread. If you need this, don't detach the thread and instead use waitThread.

Once a thread is detached, you should usually assume the SDL_Thread isn't safe to reference again, as it will become invalid immediately upon the detached thread's exit, instead of remaining until someone has called waitThread to finally clean it up. As such, don't detach the same thread more than once.

If a thread has already exited when passed to detachThread, it will stop waiting for a call to waitThread and clean up immediately. It is not safe to detach a thread that might be used with waitThread.

You may not call waitThread on a thread that has been detached. Use either that function or this one, but not both, or behavior is undefined.

It is safe to pass NULL to this function; it is a no-op.

Thread safety
It is safe to call this function from any thread.
See also
createThread, waitThread

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_DetachThread. The unsafe flavor is detachThread .
C declaration
SDL_DetachThread, defined at SDL3/SDL_thread.h 525:34

Since: 3.2.0

getTLS Source #

Arguments

:: Ptr SDL_TLSID
id
a pointer to the thread local storage ID, may not be NULL.
-> IO (Ptr Void) 

Get the current thread's value associated with a thread local storage ID.

Returns
the value associated with the ID for the current thread or NULL if no value has been set; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
setTLS

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_GetTLS. The safe flavor is getTLSSafe .
C declaration
SDL_GetTLS, defined at SDL3/SDL_thread.h 540:36

Since: 3.2.0

getTLSSafe Source #

Arguments

:: Ptr SDL_TLSID
id
a pointer to the thread local storage ID, may not be NULL.
-> IO (Ptr Void) 

Get the current thread's value associated with a thread local storage ID.

Returns
the value associated with the ID for the current thread or NULL if no value has been set; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
setTLS

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_GetTLS. The unsafe flavor is getTLS .
C declaration
SDL_GetTLS, defined at SDL3/SDL_thread.h 540:36

Since: 3.2.0

setTLS Source #

Arguments

:: Ptr SDL_TLSID
id
a pointer to the thread local storage ID, may not be NULL.
-> PtrConst Void
value
the value to associate with the ID for the current thread.
-> SDL_TLSDestructorCallback
destructor
a function called when the thread exits, to free the value, may be NULL.
-> IO Bool 

Set the current thread's value associated with a thread local storage ID.

If the thread local storage ID is not initialized (the value is 0), a new ID will be created in a thread-safe way, so all calls using a pointer to the same ID will refer to the same local storage.

Note that replacing a value from a previous call to this function on the same thread does not call the previous value's destructor!

destructor can be NULL; it is assumed that value does not need to be cleaned up if so.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getTLS

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_SetTLS. The safe flavor is setTLSSafe : registration; the destructor runs at thread cleanup.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetTLS, defined at SDL3/SDL_thread.h 581:34

Since: 3.2.0

setTLSSafe Source #

Arguments

:: Ptr SDL_TLSID
id
a pointer to the thread local storage ID, may not be NULL.
-> PtrConst Void
value
the value to associate with the ID for the current thread.
-> SDL_TLSDestructorCallback
destructor
a function called when the thread exits, to free the value, may be NULL.
-> IO Bool 

Set the current thread's value associated with a thread local storage ID.

If the thread local storage ID is not initialized (the value is 0), a new ID will be created in a thread-safe way, so all calls using a pointer to the same ID will refer to the same local storage.

Note that replacing a value from a previous call to this function on the same thread does not call the previous value's destructor!

destructor can be NULL; it is assumed that value does not need to be cleaned up if so.

Returns
true on success or false on failure; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
getTLS

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_SetTLS. The unsafe flavor is setTLS : registration; the destructor runs at thread cleanup.
Scalars
The binding generation has mapped C scalars to native Haskell scalars for this function. Pointers and structs are untouched by this best-effort mapping. Higher-level bindings are expected to map structs and pointers as appropriate.
C declaration
SDL_SetTLS, defined at SDL3/SDL_thread.h 581:34

Since: 3.2.0

cleanupTLS :: IO () Source #

Cleanup all TLS data for this thread.

If you are creating your threads outside of SDL and then calling SDL functions, you should call this function before your thread exits, to properly clean up SDL memory.

Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of SDL_CleanupTLS. The safe flavor is cleanupTLSSafe .
C declaration
SDL_CleanupTLS, defined at SDL3/SDL_thread.h 594:34

Since: 3.2.0

cleanupTLSSafe :: IO () Source #

Cleanup all TLS data for this thread.

If you are creating your threads outside of SDL and then calling SDL functions, you should call this function before your thread exits, to properly clean up SDL memory.

Thread safety
It is safe to call this function from any thread.

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of SDL_CleanupTLS. The unsafe flavor is cleanupTLS .
C declaration
SDL_CleanupTLS, defined at SDL3/SDL_thread.h 594:34

Since: 3.2.0

C shims

createThread Source #

Arguments

:: SDL_ThreadFunction
fn
the SDL_ThreadFunction function to call in the new thread.
-> PtrConst CChar
name
the name of the thread.
-> Ptr Void
data
a pointer that is passed to fn.
-> IO (Ptr SDL_Thread) 

Create a new thread with a default stack size.

The SDL_CreateThread macro as a function. Like the macro, it calls createThreadRuntime with the C runtime's thread entry and exit functions for the platform it is compiled on (_beginthreadex and _endthreadex on Windows, NULL elsewhere), so prefer it to calling createThreadRuntime directly.

This is equivalent to calling createThreadWithProperties with the following properties set:

  • SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER: fn
  • SDL_PROP_THREAD_CREATE_NAME_STRING: name
  • SDL_PROP_THREAD_CREATE_USERDATA_POINTER: data
Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
createThreadWithProperties, waitThread

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_CreateThread. The safe flavor is createThreadSafe : the entry function runs on the spawned thread, not during the call.
C declaration
lithon_SDL_CreateThread, defined at sdl3-bindgen-sys/SDL_thread_shims.h 54:31

Since: 3.2.0

createThreadSafe Source #

Arguments

:: SDL_ThreadFunction
fn
the SDL_ThreadFunction function to call in the new thread.
-> PtrConst CChar
name
the name of the thread.
-> Ptr Void
data
a pointer that is passed to fn.
-> IO (Ptr SDL_Thread) 

Create a new thread with a default stack size.

The SDL_CreateThread macro as a function. Like the macro, it calls createThreadRuntime with the C runtime's thread entry and exit functions for the platform it is compiled on (_beginthreadex and _endthreadex on Windows, NULL elsewhere), so prefer it to calling createThreadRuntime directly.

This is equivalent to calling createThreadWithProperties with the following properties set:

  • SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER: fn
  • SDL_PROP_THREAD_CREATE_NAME_STRING: name
  • SDL_PROP_THREAD_CREATE_USERDATA_POINTER: data
Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
createThreadWithProperties, waitThread

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of lithon_SDL_CreateThread. The unsafe flavor is createThread : the entry function runs on the spawned thread, not during the call.
C declaration
lithon_SDL_CreateThread, defined at sdl3-bindgen-sys/SDL_thread_shims.h 54:31

Since: 3.2.0

createThreadWithProperties Source #

Arguments

:: SDL_PropertiesID
props
the properties to use.
-> IO (Ptr SDL_Thread) 

Create a new thread with the specified properties.

The SDL_CreateThreadWithProperties macro as a function, passing the C runtime's thread entry and exit functions like createThread does.

These are the supported properties:

  • SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER: an SDL_ThreadFunction value that will be called at the start of the new thread's life. Required.
  • SDL_PROP_THREAD_CREATE_NAME_STRING: the name of the new thread, which might be available to debuggers. Optional, defaults to NULL.
  • SDL_PROP_THREAD_CREATE_USERDATA_POINTER: an arbitrary app-defined pointer, which is passed to the entry function on the new thread, as its only parameter. Optional, defaults to NULL.
  • SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER: the size, in bytes, of the new thread's stack. Optional, defaults to 0 (system-defined default).
Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
createThread, waitThread

sdl3-bindgen-sys notes

Expand
FFI safety
Unsafe foreign import of lithon_SDL_CreateThreadWithProperties. The safe flavor is createThreadWithPropertiesSafe : the entry function runs on the spawned thread, not during the call.
C declaration
lithon_SDL_CreateThreadWithProperties, defined at sdl3-bindgen-sys/SDL_thread_shims.h 90:31

Since: 3.2.0

createThreadWithPropertiesSafe Source #

Arguments

:: SDL_PropertiesID
props
the properties to use.
-> IO (Ptr SDL_Thread) 

Create a new thread with the specified properties.

The SDL_CreateThreadWithProperties macro as a function, passing the C runtime's thread entry and exit functions like createThread does.

These are the supported properties:

  • SDL_PROP_THREAD_CREATE_ENTRY_FUNCTION_POINTER: an SDL_ThreadFunction value that will be called at the start of the new thread's life. Required.
  • SDL_PROP_THREAD_CREATE_NAME_STRING: the name of the new thread, which might be available to debuggers. Optional, defaults to NULL.
  • SDL_PROP_THREAD_CREATE_USERDATA_POINTER: an arbitrary app-defined pointer, which is passed to the entry function on the new thread, as its only parameter. Optional, defaults to NULL.
  • SDL_PROP_THREAD_CREATE_STACKSIZE_NUMBER: the size, in bytes, of the new thread's stack. Optional, defaults to 0 (system-defined default).
Returns
an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call getError for more information.
Thread safety
It is safe to call this function from any thread.
See also
createThread, waitThread

sdl3-bindgen-sys notes

Expand
FFI safety
Safe foreign import of lithon_SDL_CreateThreadWithProperties. The unsafe flavor is createThreadWithProperties : the entry function runs on the spawned thread, not during the call.
C declaration
lithon_SDL_CreateThreadWithProperties, defined at sdl3-bindgen-sys/SDL_thread_shims.h 90:31

Since: 3.2.0