| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Bindgen.Thread.FunPtr
Synopsis
- sDL_CreateThreadRuntime :: FunPtr (SDL_ThreadFunction -> PtrConst CChar -> Ptr Void -> SDL_FunctionPointer -> SDL_FunctionPointer -> IO (Ptr SDL_Thread))
- sDL_CreateThreadWithPropertiesRuntime :: FunPtr (SDL_PropertiesID -> SDL_FunctionPointer -> SDL_FunctionPointer -> IO (Ptr SDL_Thread))
- sDL_GetThreadName :: FunPtr (Ptr SDL_Thread -> IO (PtrConst CChar))
- sDL_GetCurrentThreadID :: FunPtr (IO SDL_ThreadID)
- sDL_GetThreadID :: FunPtr (Ptr SDL_Thread -> IO SDL_ThreadID)
- sDL_SetCurrentThreadPriority :: FunPtr (SDL_ThreadPriority -> IO CBool)
- sDL_WaitThread :: FunPtr (Ptr SDL_Thread -> Ptr CInt -> IO ())
- sDL_GetThreadState :: FunPtr (Ptr SDL_Thread -> IO SDL_ThreadState)
- sDL_DetachThread :: FunPtr (Ptr SDL_Thread -> IO ())
- sDL_GetTLS :: FunPtr (Ptr SDL_TLSID -> IO (Ptr Void))
- sDL_SetTLS :: FunPtr (Ptr SDL_TLSID -> PtrConst Void -> SDL_TLSDestructorCallback -> IO CBool)
- sDL_CleanupTLS :: FunPtr (IO ())
Documentation
sDL_CreateThreadRuntime :: FunPtr (SDL_ThreadFunction -> PtrConst CChar -> Ptr Void -> SDL_FunctionPointer -> SDL_FunctionPointer -> IO (Ptr SDL_Thread)) Source #
The actual entry point for SDL_CreateThread.
fn- the
SDL_ThreadFunctionfunction to call in the new thread name- the name of the thread
data- a pointer that is passed to
fn pfnBeginThread- the C runtime's _beginthreadex (or whatnot). Can be NULL.
pfnEndThread- the C runtime's _endthreadex (or whatnot). Can be NULL.
- Returns
- an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call SDL_GetError() for more information.
- Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_CreateThreadRuntime, defined atSDL3/SDL_thread.h 340:42
Since: 3.2.0
sDL_CreateThreadWithPropertiesRuntime :: FunPtr (SDL_PropertiesID -> SDL_FunctionPointer -> SDL_FunctionPointer -> IO (Ptr SDL_Thread)) Source #
The actual entry point for SDL_CreateThreadWithProperties.
props- the properties to use
pfnBeginThread- the C runtime's _beginthreadex (or whatnot). Can be NULL.
pfnEndThread- the C runtime's _endthreadex (or whatnot). Can be NULL.
- Returns
- an opaque pointer to the new thread object on success, NULL if the new thread could not be created; call SDL_GetError() for more information.
- Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_CreateThreadWithPropertiesRuntime, defined atSDL3/SDL_thread.h 356:42
Since: 3.2.0
sDL_GetThreadName :: FunPtr (Ptr SDL_Thread -> IO (PtrConst CChar)) Source #
Get the thread name as it was specified in SDL_CreateThread().
thread- the thread to query.
- 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.
- C declaration
SDL_GetThreadName, defined atSDL3/SDL_thread.h 378:42
Since: 3.2.0
sDL_GetCurrentThreadID :: FunPtr (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
sDL_GetThreadID- C declaration
SDL_GetCurrentThreadID, defined atSDL3/SDL_thread.h 398:42
Since: 3.2.0
sDL_GetThreadID :: FunPtr (Ptr SDL_Thread -> IO SDL_ThreadID) Source #
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.
thread- the thread to query.
- Returns
- the ID of the specified thread, or the ID of the current thread if
threadis NULL. - Thread safety
- It is safe to call this function from any thread.
- See also
sDL_GetCurrentThreadID- C declaration
SDL_GetThreadID, defined atSDL3/SDL_thread.h 417:42
Since: 3.2.0
sDL_SetCurrentThreadPriority :: FunPtr (SDL_ThreadPriority -> IO CBool) Source #
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.
priority- the
SDL_ThreadPriorityto set. - Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Thread safety
- It is safe to call this function from any thread.
- C declaration
SDL_SetCurrentThreadPriority, defined atSDL3/SDL_thread.h 434:34
Since: 3.2.0
sDL_WaitThread :: FunPtr (Ptr SDL_Thread -> Ptr CInt -> IO ()) Source #
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 SDL_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 SDL_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- the
SDL_Threadpointer that was returned from theSDL_CreateThread()call that started this thread. 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.
- 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
SDL_CreateThread,sDL_DetachThread- C declaration
SDL_WaitThread, defined atSDL3/SDL_thread.h 472:34
Since: 3.2.0
sDL_GetThreadState :: FunPtr (Ptr SDL_Thread -> IO SDL_ThreadState) Source #
Get the current state of a thread.
thread- the thread to query.
- 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- C declaration
SDL_GetThreadState, defined atSDL3/SDL_thread.h 487:45
Since: 3.2.0
sDL_DetachThread :: FunPtr (Ptr SDL_Thread -> IO ()) Source #
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 SDL_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 SDL_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 SDL_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 SDL_DetachThread(), it will stop waiting for a call to SDL_WaitThread() and clean up immediately. It is not safe to detach a thread that might be used with SDL_WaitThread().
You may not call SDL_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- the
SDL_Threadpointer that was returned from theSDL_CreateThread()call that started this thread. - Thread safety
- It is safe to call this function from any thread.
- See also
SDL_CreateThread,sDL_WaitThread- C declaration
SDL_DetachThread, defined atSDL3/SDL_thread.h 525:34
Since: 3.2.0
sDL_GetTLS :: FunPtr (Ptr SDL_TLSID -> IO (Ptr Void)) Source #
Get the current thread's value associated with a thread local storage ID.
id- a pointer to the thread local storage ID, may not be NULL.
- Returns
- the value associated with the ID for the current thread or NULL if no value has been set; call SDL_GetError() for more information.
- Thread safety
- It is safe to call this function from any thread.
- See also
sDL_SetTLS- C declaration
SDL_GetTLS, defined atSDL3/SDL_thread.h 540:36
Since: 3.2.0
sDL_SetTLS :: FunPtr (Ptr SDL_TLSID -> PtrConst Void -> SDL_TLSDestructorCallback -> IO CBool) Source #
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.
id- a pointer to the thread local storage ID, may not be NULL.
value- the value to associate with the ID for the current thread.
destructor- a function called when the thread exits, to free the value, may be NULL.
- Returns
- true on success or false on failure; call SDL_GetError() for more information.
- Thread safety
- It is safe to call this function from any thread.
- See also
sDL_GetTLS- C declaration
SDL_SetTLS, defined atSDL3/SDL_thread.h 581:34
Since: 3.2.0
sDL_CleanupTLS :: FunPtr (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.
- C declaration
SDL_CleanupTLS, defined atSDL3/SDL_thread.h 594:34
Since: 3.2.0