RetroArch
lwp.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------
2 
3 lwp.h -- Thread subsystem I
4 
5 Copyright (C) 2004
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
8 
9 This software is provided 'as-is', without any express or implied
10 warranty. In no event will the authors be held liable for any
11 damages arising from the use of this software.
12 
13 Permission is granted to anyone to use this software for any
14 purpose, including commercial applications, and to alter it and
15 redistribute it freely, subject to the following restrictions:
16 
17 1. The origin of this software must not be misrepresented; you
18 must not claim that you wrote the original software. If you use
19 this software in a product, an acknowledgment in the product
20 documentation would be appreciated but is not required.
21 
22 2. Altered source versions must be plainly marked as such, and
23 must not be misrepresented as being the original software.
24 
25 3. This notice may not be removed or altered from any source
26 distribution.
27 
28 
29 
30 -------------------------------------------------------------*/
31 
32 
33 #ifndef __LWP_H__
34 #define __LWP_H__
35 
41 #include <gctypes.h>
42 
43 #define LWP_CLOSED -1
44 #define LWP_SUCCESSFUL 0
45 #define LWP_ALREADY_SUSPENDED 1
46 #define LWP_NOT_SUSPENDED 2
47 
48 #define LWP_PRIO_IDLE 0
49 #define LWP_PRIO_HIGHEST 127
50 
51 #define LWP_THREAD_NULL 0xffffffff
52 #define LWP_TQUEUE_NULL 0xffffffff
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 
62 typedef u32 lwp_t;
63 
64 
68 typedef u32 lwpq_t;
69 
81 s32 LWP_CreateThread(lwp_t *thethread,void* (*entry)(void *),void *arg,void *stackbase,u32 stack_size,u8 prio);
82 
83 
90 s32 LWP_SuspendThread(lwp_t thethread);
91 
92 
99 s32 LWP_ResumeThread(lwp_t thethread);
100 
101 
108 BOOL LWP_ThreadIsSuspended(lwp_t thethread);
109 
110 
117 
118 
126 void LWP_SetThreadPriority(lwp_t thethread,u32 prio);
127 
128 
134 void LWP_YieldThread();
135 
136 
143 void LWP_Reschedule(u32 prio);
144 
145 
153 s32 LWP_JoinThread(lwp_t thethread,void **value_ptr);
154 
155 
162 s32 LWP_InitQueue(lwpq_t *thequeue);
163 
164 
171 void LWP_CloseQueue(lwpq_t thequeue);
172 
173 
180 s32 LWP_ThreadSleep(lwpq_t thequeue);
181 
182 
189 void LWP_ThreadSignal(lwpq_t thequeue);
190 
191 
198 void LWP_ThreadBroadcast(lwpq_t thequeue);
199 
200 #ifdef __cplusplus
201  }
202 #endif
203 
204 #endif
s32 LWP_ThreadSleep(lwpq_t thequeue)
Pushes the current thread onto the given thread synchronization queue and sets the thread state to bl...
Definition: lwp.c:369
int32_t s32
32bit signed integer
Definition: gctypes.h:24
void LWP_YieldThread()
Yield the current thread to another one with higher priority or if not running at the same priority w...
Definition: lwp.c:276
BOOL LWP_ThreadIsSuspended(lwp_t thethread)
Test whether the given thread is suspended or not.
Definition: lwp.c:290
s32 LWP_InitQueue(lwpq_t *thequeue)
Initialize the thread synchronization queue.
Definition: lwp.c:335
Data type definitions.
s32 LWP_CreateThread(lwp_t *thethread, void *(*entry)(void *), void *arg, void *stackbase, u32 stack_size, u8 prio)
Definition: lwp.c:190
void LWP_Reschedule(u32 prio)
Reschedule all threads running at the given priority.
Definition: lwp.c:283
s32 LWP_SuspendThread(lwp_t thethread)
Suspend the given thread.
Definition: lwp.c:220
u32 lwp_t
typedef for the thread context handle
Definition: lwp.h:62
s32 LWP_JoinThread(lwp_t thethread, void **value_ptr)
Join the given thread.
Definition: lwp.c:305
void LWP_CloseQueue(lwpq_t thequeue)
Close the thread synchronization queue and releas the handle.
Definition: lwp.c:352
u32 lwpq_t
typedef for the thread queue's context handle
Definition: lwp.h:68
lwp_t LWP_GetSelf()
Return the handle to the current thread.
Definition: lwp.c:252
s32 LWP_ResumeThread(lwp_t thethread)
Resume the given thread.
Definition: lwp.c:236
void LWP_ThreadBroadcast(lwpq_t thequeue)
Removes all blocked threads from the thread synchronization queue and sets them back to running state...
Definition: lwp.c:392
unsigned int BOOL
Definition: gctypes.h:51
void LWP_ThreadSignal(lwpq_t thequeue)
Signals one thread to be revmoved from the thread synchronization queue and sets it back to running s...
Definition: lwp.c:406
void LWP_SetThreadPriority(lwp_t thethread, u32 prio)
Set the priority of the given thread.
Definition: lwp.c:263
uint8_t u8
8bit unsigned integer
Definition: gctypes.h:17
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19