orx  1.14
Portable Game Engine
OrxThread

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
 

Functions

orxDLLAPI orxTHREAD_SEMAPHORE *orxFASTCALL orxThread_CreateSemaphore (orxU32 _u32Value)
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_DeleteSemaphore (orxTHREAD_SEMAPHORE *_pstSemaphore)
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Enable (orxU32 _u32EnableThreads, orxU32 _u32DisableThreads)
 
orxDLLAPI void orxFASTCALL orxThread_Exit ()
 
orxDLLAPI orxU32 orxFASTCALL orxThread_GetCurrent ()
 
orxDLLAPI const orxSTRING orxFASTCALL orxThread_GetName (orxU32 _u32ThreadID)
 
orxDLLAPI orxU32 orxFASTCALL orxThread_GetTaskCount ()
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Init ()
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Join (orxU32 _u32ThreadID)
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_JoinAll ()
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_RunTask (const orxTHREAD_FUNCTION _pfnRun, const orxTHREAD_FUNCTION _pfnThen, const orxTHREAD_FUNCTION _pfnElse, void *_pContext)
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_SetCallbacks (const orxTHREAD_FUNCTION _pfnStart, const orxTHREAD_FUNCTION _pfnStop, void *_pContext)
 
orxDLLAPI void orxFASTCALL orxThread_Setup ()
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_SignalSemaphore (orxTHREAD_SEMAPHORE *_pstSemaphore)
 
orxDLLAPI orxU32 orxFASTCALL orxThread_Start (const orxTHREAD_FUNCTION _pfnRun, const orxSTRING _zName, void *_pContext)
 
orxDLLAPI orxSTATUS orxFASTCALL orxThread_WaitSemaphore (orxTHREAD_SEMAPHORE *_pstSemaphore)
 
orxDLLAPI void orxFASTCALL orxThread_Yield ()
 

Detailed Description

Thread file Code that handles threads

Macro Definition Documentation

#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.

Typedef Documentation

typedef orxSTATUS(orxFASTCALL * orxTHREAD_FUNCTION) (void *_pContext)

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.

Function Documentation

orxDLLAPI orxTHREAD_SEMAPHORE* orxFASTCALL orxThread_CreateSemaphore ( orxU32  _u32Value)

Inits a semaphore with a given value

Parameters
[in]_u32ValueValue with which to init the semaphore
Returns
orxTHREAD_SEMAPHORE / orxNULL
orxDLLAPI orxSTATUS orxFASTCALL orxThread_DeleteSemaphore ( orxTHREAD_SEMAPHORE _pstSemaphore)

Deletes a semaphore

Parameters
[in]_pstSemaphoreConcerned semaphore
Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Enable ( orxU32  _u32EnableThreads,
orxU32  _u32DisableThreads 
)

Enables / disables threads

Parameters
[in]_u32EnableThreadsMask of threads to enable (1 << ThreadID)
[in]_u32DisableThreadsMask of threads to disable (1 << ThreadID)
Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
orxDLLAPI void orxFASTCALL orxThread_Exit ( )

Exits from the thread module

orxDLLAPI orxU32 orxFASTCALL orxThread_GetCurrent ( )

Gets current thread ID

Returns
Current thread ID
orxDLLAPI const orxSTRING orxFASTCALL orxThread_GetName ( orxU32  _u32ThreadID)

Gets a thread name

Parameters
[in]_u32ThreadIDID of the concerned thread
Returns
Thread name
orxDLLAPI orxU32 orxFASTCALL orxThread_GetTaskCount ( )

Gets number of pending asynchronous tasks awaiting full completion (might pump task notifications if called from main thread)

Returns
Number of pending asynchronous tasks
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Init ( )

Inits the thread module

Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Join ( orxU32  _u32ThreadID)

Joins a thread (blocks & waits until the other thread finishes)

Parameters
[in]_u32ThreadIDID of the thread for which to wait
Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
orxDLLAPI orxSTATUS orxFASTCALL orxThread_JoinAll ( )

Joins all threads (blocks & waits until the other threads finish)

Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
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

Parameters
[in]_pfnRunAsynchronous task to run, executed on a different thread dedicated to tasks, if orxNULL defaults to an empty task that always succeed
[in]_pfnThenExecuted (on the main thread) if Run does not return orxSTATUS_FAILURE, can be orxNULL
[in]_pfnElseExecuted (on the main thread) if Run returns orxSTATUS_FAILURE, can be orxNULL
[in]_pContextContext that will be transmitted to all the task functions
Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
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

Parameters
[in]_pfnStartFunction to run whenever a new thread is started
[in]_pfnStopFunction to run whenever a thread is stopped
[in]_pContextContext that will be transmitted to each callback
Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
orxDLLAPI void orxFASTCALL orxThread_Setup ( )

Thread module setup

orxDLLAPI orxSTATUS orxFASTCALL orxThread_SignalSemaphore ( orxTHREAD_SEMAPHORE _pstSemaphore)

Signals a semaphore

Parameters
[in]_pstSemaphoreConcerned semaphore
Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
orxDLLAPI orxU32 orxFASTCALL orxThread_Start ( const orxTHREAD_FUNCTION  _pfnRun,
const orxSTRING  _zName,
void _pContext 
)

Starts a new thread

Parameters
[in]_pfnRunFunction to run on the new thread
[in]_zNameThread's name
[in]_pContextContext that will be transmitted to the function when called
Returns
Thread ID if successful, orxU32_UNDEFINED otherwise
orxDLLAPI orxSTATUS orxFASTCALL orxThread_WaitSemaphore ( orxTHREAD_SEMAPHORE _pstSemaphore)

Waits for a semaphore

Parameters
[in]_pstSemaphoreConcerned semaphore
Returns
orxSTATUS_SUCCESS / orxSTATUS_FAILURE
orxDLLAPI void orxFASTCALL orxThread_Yield ( )

Yields to other threads


Generated for orx by doxygen 1.8.11