orx  stable
Portable Game Engine
orxThread.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2017 Orx-Project
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  *
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  * misrepresented as being the original software.
20  *
21  * 3. This notice may not be removed or altered from any source
22  * distribution.
23  */
24 
43 #ifndef _orxTHREAD_H_
44 #define _orxTHREAD_H_
45 
46 #include "orxInclude.h"
47 
48 #ifdef __orxWINDOWS__
49  #include "memory/orxMemory.h"
50 #else /* __orxWINDOWS__ */
51  #include <semaphore.h>
52 #endif /* __orxWINDOWS__ */
53 
54 
55 #define orxTHREAD_KU32_MAIN_THREAD_ID 0
56 #define orxTHREAD_KU32_MAX_THREAD_NUMBER 16
58 #define orxTHREAD_KU32_FLAG_NONE 0
59 #define orxTHREAD_KU32_MASK_ALL (((1 << orxTHREAD_KU32_MAX_THREAD_NUMBER) - 1) & ~(1 << orxTHREAD_KU32_MAIN_THREAD_ID)) /* Mask all (for orxThread_Enable) */
60 #define orxTHREAD_GET_FLAG_FROM_ID(ID) (1 << ID)
64 typedef struct __orxTHREAD_SEMAPHORE_t orxTHREAD_SEMAPHORE;
65 
66 
68 typedef orxSTATUS (orxFASTCALL *orxTHREAD_FUNCTION)(void *_pContext);
69 
70 
73 extern orxDLLAPI void orxFASTCALL orxThread_Setup();
74 
78 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_Init();
79 
82 extern orxDLLAPI void orxFASTCALL orxThread_Exit();
83 
84 
91 extern orxDLLAPI orxU32 orxFASTCALL orxThread_Start(const orxTHREAD_FUNCTION _pfnRun, const orxSTRING _zName, void *_pContext);
92 
97 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_Join(orxU32 _u32ThreadID);
98 
102 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_JoinAll();
103 
108 extern orxDLLAPI const orxSTRING orxFASTCALL orxThread_GetName(orxU32 _u32ThreadID);
109 
115 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_Enable(orxU32 _u32EnableThreads, orxU32 _u32DisableThreads);
116 
120 extern orxDLLAPI orxU32 orxFASTCALL orxThread_GetCurrent();
121 
124 extern orxDLLAPI void orxFASTCALL orxThread_Yield();
125 
126 
131 extern orxDLLAPI orxTHREAD_SEMAPHORE *orxFASTCALL orxThread_CreateSemaphore(orxU32 _u32Value);
132 
137 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_DeleteSemaphore(orxTHREAD_SEMAPHORE *_pstSemaphore);
138 
143 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_WaitSemaphore(orxTHREAD_SEMAPHORE *_pstSemaphore);
144 
149 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_SignalSemaphore(orxTHREAD_SEMAPHORE *_pstSemaphore);
150 
151 
159 extern orxDLLAPI orxSTATUS orxFASTCALL orxThread_RunTask(const orxTHREAD_FUNCTION _pfnRun, const orxTHREAD_FUNCTION _pfnThen, const orxTHREAD_FUNCTION _pfnElse, void *_pContext);
160 
164 extern orxDLLAPI orxU32 orxFASTCALL orxThread_GetTaskCounter();
165 
166 
167 #endif /* _orxTHREAD_H_ */
168 
orxDLLAPI void orxFASTCALL orxThread_Exit()
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Enable(orxU32 _u32EnableThreads, orxU32 _u32DisableThreads)
orxDLLAPI void orxFASTCALL orxThread_Yield()
orxDLLAPI orxSTATUS orxFASTCALL orxThread_RunTask(const orxTHREAD_FUNCTION _pfnRun, const orxTHREAD_FUNCTION _pfnThen, const orxTHREAD_FUNCTION _pfnElse, void *_pContext)
struct __orxTHREAD_SEMAPHORE_t orxTHREAD_SEMAPHORE
Definition: orxThread.h:64
orxDLLAPI orxSTATUS orxFASTCALL orxThread_SignalSemaphore(orxTHREAD_SEMAPHORE *_pstSemaphore)
orxDLLAPI void orxFASTCALL orxThread_Setup()
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Join(orxU32 _u32ThreadID)
orxDLLAPI orxSTATUS orxFASTCALL orxThread_Init()
orxSTATUS
Definition: orxType.h:243
orxDLLAPI orxSTATUS orxFASTCALL orxThread_JoinAll()
#define orxDLLAPI
Definition: orxDecl.h:387
orxDLLAPI orxSTATUS orxFASTCALL orxThread_DeleteSemaphore(orxTHREAD_SEMAPHORE *_pstSemaphore)
orxSTATUS(orxFASTCALL * orxTHREAD_FUNCTION)(void *_pContext)
Definition: orxThread.h:68
orxDLLAPI const orxSTRING orxFASTCALL orxThread_GetName(orxU32 _u32ThreadID)
orxDLLAPI orxTHREAD_SEMAPHORE *orxFASTCALL orxThread_CreateSemaphore(orxU32 _u32Value)
orxDLLAPI orxU32 orxFASTCALL orxThread_GetTaskCounter()
orxDLLAPI orxU32 orxFASTCALL orxThread_Start(const orxTHREAD_FUNCTION _pfnRun, const orxSTRING _zName, void *_pContext)
orxDLLAPI orxU32 orxFASTCALL orxThread_GetCurrent()
orxDLLAPI orxSTATUS orxFASTCALL orxThread_WaitSemaphore(orxTHREAD_SEMAPHORE *_pstSemaphore)

Generated for orx by doxygen 1.5.6