orx
1.14
Portable Game Engine
|
Macros | |
#define | orxTHREAD_GET_FLAG_FROM_ID(ID) (1 << (ID)) |
#define | orxTHREAD_KU32_FLAG_NONE 0 |
#define | orxTHREAD_KU32_MAIN_THREAD_ID 0 |
#define | orxTHREAD_KU32_MASK_ALL (((1 << orxTHREAD_KU32_MAX_THREAD_NUMBER) - 1) & ~(1 << orxTHREAD_KU32_MAIN_THREAD_ID)) /* Mask all (for orxThread_Enable) */ |
#define | orxTHREAD_KU32_MAX_THREAD_NUMBER 16 |
Typedefs | |
typedef orxSTATUS(orxFASTCALL * | orxTHREAD_FUNCTION) (void *_pContext) |
typedef struct __orxTHREAD_SEMAPHORE_t | orxTHREAD_SEMAPHORE |
Thread file Code that handles threads
#define orxTHREAD_GET_FLAG_FROM_ID | ( | ID | ) | (1 << (ID)) |
Gets thread flag from ID
Definition at line 60 of file orxThread.h.
#define orxTHREAD_KU32_FLAG_NONE 0 |
Flag none (for orxThread_Enable)
Definition at line 58 of file orxThread.h.
#define orxTHREAD_KU32_MAIN_THREAD_ID 0 |
Main thread ID
Definition at line 55 of file orxThread.h.
#define orxTHREAD_KU32_MASK_ALL (((1 << orxTHREAD_KU32_MAX_THREAD_NUMBER) - 1) & ~(1 << orxTHREAD_KU32_MAIN_THREAD_ID)) /* Mask all (for orxThread_Enable) */ |
Definition at line 59 of file orxThread.h.
#define orxTHREAD_KU32_MAX_THREAD_NUMBER 16 |
Max thread number
Definition at line 56 of file orxThread.h.
Thread run function type
Definition at line 68 of file orxThread.h.
typedef struct __orxTHREAD_SEMAPHORE_t orxTHREAD_SEMAPHORE |
Semaphore structure
Definition at line 64 of file orxThread.h.
orxDLLAPI orxTHREAD_SEMAPHORE* orxFASTCALL orxThread_CreateSemaphore | ( | orxU32 | _u32Value | ) |
Inits a semaphore with a given value
[in] | _u32Value | Value with which to init the semaphore |
orxDLLAPI orxSTATUS orxFASTCALL orxThread_DeleteSemaphore | ( | orxTHREAD_SEMAPHORE * | _pstSemaphore | ) |
Deletes a semaphore
[in] | _pstSemaphore | Concerned semaphore |
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Enable | ( | orxU32 | _u32EnableThreads, |
orxU32 | _u32DisableThreads | ||
) |
Enables / disables threads
[in] | _u32EnableThreads | Mask of threads to enable (1 << ThreadID) |
[in] | _u32DisableThreads | Mask of threads to disable (1 << ThreadID) |
orxDLLAPI orxU32 orxFASTCALL orxThread_GetCurrent | ( | ) |
Gets current thread ID
orxDLLAPI const orxSTRING orxFASTCALL orxThread_GetName | ( | orxU32 | _u32ThreadID | ) |
Gets a thread name
[in] | _u32ThreadID | ID of the concerned thread |
orxDLLAPI orxU32 orxFASTCALL orxThread_GetTaskCount | ( | ) |
Gets number of pending asynchronous tasks awaiting full completion (might pump task notifications if called from main thread)
Inits the thread module
Joins a thread (blocks & waits until the other thread finishes)
[in] | _u32ThreadID | ID of the thread for which to wait |
Joins all threads (blocks & waits until the other threads finish)
orxDLLAPI orxSTATUS orxFASTCALL orxThread_RunTask | ( | const orxTHREAD_FUNCTION | _pfnRun, |
const orxTHREAD_FUNCTION | _pfnThen, | ||
const orxTHREAD_FUNCTION | _pfnElse, | ||
void * | _pContext | ||
) |
Runs an asynchronous task and optional follow-ups
[in] | _pfnRun | Asynchronous task to run, executed on a different thread dedicated to tasks, if orxNULL defaults to an empty task that always succeed |
[in] | _pfnThen | Executed (on the main thread) if Run does not return orxSTATUS_FAILURE, can be orxNULL |
[in] | _pfnElse | Executed (on the main thread) if Run returns orxSTATUS_FAILURE, can be orxNULL |
[in] | _pContext | Context that will be transmitted to all the task functions |
orxDLLAPI orxSTATUS orxFASTCALL orxThread_SetCallbacks | ( | const orxTHREAD_FUNCTION | _pfnStart, |
const orxTHREAD_FUNCTION | _pfnStop, | ||
void * | _pContext | ||
) |
Sets callbacks to run when starting and stopping new threads
[in] | _pfnStart | Function to run whenever a new thread is started |
[in] | _pfnStop | Function to run whenever a thread is stopped |
[in] | _pContext | Context that will be transmitted to each callback |
orxDLLAPI orxSTATUS orxFASTCALL orxThread_SignalSemaphore | ( | orxTHREAD_SEMAPHORE * | _pstSemaphore | ) |
Signals a semaphore
[in] | _pstSemaphore | Concerned semaphore |
orxDLLAPI orxU32 orxFASTCALL orxThread_Start | ( | const orxTHREAD_FUNCTION | _pfnRun, |
const orxSTRING | _zName, | ||
void * | _pContext | ||
) |
Starts a new thread
[in] | _pfnRun | Function to run on the new thread |
[in] | _zName | Thread's name |
[in] | _pContext | Context that will be transmitted to the function when called |
orxDLLAPI orxSTATUS orxFASTCALL orxThread_WaitSemaphore | ( | orxTHREAD_SEMAPHORE * | _pstSemaphore | ) |
Waits for a semaphore
[in] | _pstSemaphore | Concerned semaphore |