|
1 /* |
|
2 * Copyright (c) 1999 - 2003 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /***************************************************************** |
|
20 |
|
21 Subsystem Name: Operating System Utilities |
|
22 Version: V1.0 |
|
23 Description: |
|
24 Provides interfaces to common system utilities like; |
|
25 threads, mutexes, etc |
|
26 |
|
27 ******************************************************************/ |
|
28 #ifndef NWX_OSU_H |
|
29 #define NWX_OSU_H |
|
30 |
|
31 #ifdef __cplusplus |
|
32 extern "C" { |
|
33 #endif |
|
34 |
|
35 /* |
|
36 ** Includes |
|
37 */ |
|
38 #include "nwx_defs.h" |
|
39 #include "BrsrStatusCodes.h" |
|
40 |
|
41 /* |
|
42 ** Type Definitions |
|
43 */ |
|
44 |
|
45 #define NW_WAIT_FOREVER -1 |
|
46 #define NW_WAIT_UNSPECIFIED -2 |
|
47 |
|
48 |
|
49 /* |
|
50 ** These OSU types should be opaque to the user. |
|
51 ** They are returned from, and passed to, the OSU functions |
|
52 ** but they are never manipulated directly by the user. |
|
53 */ |
|
54 |
|
55 typedef void* NW_Osu_Thread_t; |
|
56 typedef void* NW_Osu_SemaphoreHandle_t; |
|
57 typedef void* NW_Osu_Mutex_t; |
|
58 typedef void* NW_Osu_File_t; |
|
59 typedef void* NW_Osu_Signal_t; |
|
60 typedef NW_Uint32 NW_Osu_ThreadId_t; |
|
61 typedef void* NW_Osu_Hwnd_t; |
|
62 |
|
63 /* |
|
64 ** Global Function Declarations |
|
65 */ |
|
66 |
|
67 /*********************** Mutex Functions ************************************/ |
|
68 |
|
69 /* create a new mutex object */ |
|
70 NW_Osu_Mutex_t NW_Osu_NewMutex(const char *name); |
|
71 |
|
72 /* wait for the mutex to be unlocked and then lock it */ |
|
73 TBrowserStatusCode NW_Osu_LockMutex(NW_Osu_Mutex_t handle); |
|
74 |
|
75 /* unlock a mutex */ |
|
76 TBrowserStatusCode NW_Osu_UnlockMutex(NW_Osu_Mutex_t handle); |
|
77 |
|
78 /* delete a mutex object */ |
|
79 void NW_Osu_DeleteMutex(NW_Osu_Mutex_t handle); |
|
80 |
|
81 |
|
82 /*********************** Signal Functions ************************************/ |
|
83 |
|
84 /* create a new signal object */ |
|
85 NW_Osu_Signal_t NW_Osu_NewSignal(const char *name); |
|
86 |
|
87 /* set the signal */ |
|
88 TBrowserStatusCode NW_Osu_NotifySignal(NW_Osu_Signal_t handle); |
|
89 |
|
90 /* wait for a signal to be set */ |
|
91 TBrowserStatusCode NW_Osu_WaitOnSignal(NW_Osu_Signal_t handle, const NW_Int32 howLong); |
|
92 |
|
93 /* delete a signal object */ |
|
94 void NW_Osu_DeleteSignal(NW_Osu_Signal_t handle); |
|
95 |
|
96 |
|
97 /************************* Thread Functions **********************************/ |
|
98 |
|
99 typedef TBrowserStatusCode NW_Osu_StartRoutine_t(void *argument); |
|
100 |
|
101 /* Return ID of current thread */ |
|
102 NW_Osu_ThreadId_t NW_Osu_GetCurrentThreadId(); |
|
103 |
|
104 |
|
105 /************************* Critical Section Functions ************************/ |
|
106 |
|
107 /* Enter a mutex protected critical section */ |
|
108 TBrowserStatusCode NW_Osu_BeginCriticalSection(); |
|
109 |
|
110 /* Leave a mutex protected critical section */ |
|
111 TBrowserStatusCode NW_Osu_EndCriticalSection(); |
|
112 |
|
113 /************************* Timer Function ***********************************/ |
|
114 |
|
115 /* Wait a specified number of microseconds */ |
|
116 void NW_Osu_Wait(NW_Int32 anInterval); |
|
117 |
|
118 #ifdef __cplusplus |
|
119 } /* extern "C" */ |
|
120 #endif |
|
121 |
|
122 #endif /* NWX_OSU_H */ |