Mercurial > sdl-ios-xcode
comparison include/SDL_mutex.h @ 4217:4c4113c2162c SDL-1.2
Fixed bug #706
Ken Bull 2009-02-25 13:22:02 PST
Adds Doxygen support for all headers (except config and boilerplate headers) in
the include folder for SDL-1.2 revision 4446.
While in general SDL is quite thoroughly commented, none of these comments are
correctly formatted for Doxygen and are generally inconsistent in their
formatting.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 21 Sep 2009 09:38:10 +0000 |
parents | a1b03ba2fcd0 |
children |
comparison
equal
deleted
inserted
replaced
4216:5b99971a27b4 | 4217:4c4113c2162c |
---|---|
21 */ | 21 */ |
22 | 22 |
23 #ifndef _SDL_mutex_h | 23 #ifndef _SDL_mutex_h |
24 #define _SDL_mutex_h | 24 #define _SDL_mutex_h |
25 | 25 |
26 /* Functions to provide thread synchronization primitives | 26 /** @file SDL_mutex.h |
27 | 27 * Functions to provide thread synchronization primitives |
28 These are independent of the other SDL routines. | 28 * |
29 */ | 29 * @note These are independent of the other SDL routines. |
30 */ | |
30 | 31 |
31 #include "SDL_stdinc.h" | 32 #include "SDL_stdinc.h" |
32 #include "SDL_error.h" | 33 #include "SDL_error.h" |
33 | 34 |
34 #include "begin_code.h" | 35 #include "begin_code.h" |
35 /* Set up for C function definitions, even when using C++ */ | 36 /* Set up for C function definitions, even when using C++ */ |
36 #ifdef __cplusplus | 37 #ifdef __cplusplus |
37 extern "C" { | 38 extern "C" { |
38 #endif | 39 #endif |
39 | 40 |
40 /* Synchronization functions which can time out return this value | 41 /** Synchronization functions which can time out return this value |
41 if they time out. | 42 * if they time out. |
42 */ | 43 */ |
43 #define SDL_MUTEX_TIMEDOUT 1 | 44 #define SDL_MUTEX_TIMEDOUT 1 |
44 | 45 |
45 /* This is the timeout value which corresponds to never time out */ | 46 /** This is the timeout value which corresponds to never time out */ |
46 #define SDL_MUTEX_MAXWAIT (~(Uint32)0) | 47 #define SDL_MUTEX_MAXWAIT (~(Uint32)0) |
47 | 48 |
48 | 49 |
49 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 50 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
50 /* Mutex functions */ | 51 /** @name Mutex functions */ /*@{*/ |
51 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 52 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
52 | 53 |
53 /* The SDL mutex structure, defined in SDL_mutex.c */ | 54 /** The SDL mutex structure, defined in SDL_mutex.c */ |
54 struct SDL_mutex; | 55 struct SDL_mutex; |
55 typedef struct SDL_mutex SDL_mutex; | 56 typedef struct SDL_mutex SDL_mutex; |
56 | 57 |
57 /* Create a mutex, initialized unlocked */ | 58 /** Create a mutex, initialized unlocked */ |
58 extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); | 59 extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); |
59 | 60 |
60 /* Lock the mutex (Returns 0, or -1 on error) */ | |
61 #define SDL_LockMutex(m) SDL_mutexP(m) | 61 #define SDL_LockMutex(m) SDL_mutexP(m) |
62 /** Lock the mutex | |
63 * @return 0, or -1 on error | |
64 */ | |
62 extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); | 65 extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); |
63 | 66 |
64 /* Unlock the mutex (Returns 0, or -1 on error) | 67 #define SDL_UnlockMutex(m) SDL_mutexV(m) |
65 It is an error to unlock a mutex that has not been locked by | 68 /** Unlock the mutex |
66 the current thread, and doing so results in undefined behavior. | 69 * @return 0, or -1 on error |
70 * | |
71 * It is an error to unlock a mutex that has not been locked by | |
72 * the current thread, and doing so results in undefined behavior. | |
67 */ | 73 */ |
68 #define SDL_UnlockMutex(m) SDL_mutexV(m) | |
69 extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); | 74 extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); |
70 | 75 |
71 /* Destroy a mutex */ | 76 /** Destroy a mutex */ |
72 extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); | 77 extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); |
73 | 78 |
79 /*@}*/ | |
74 | 80 |
75 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 81 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
76 /* Semaphore functions */ | 82 /** @name Semaphore functions */ /*@{*/ |
77 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 83 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
78 | 84 |
79 /* The SDL semaphore structure, defined in SDL_sem.c */ | 85 /** The SDL semaphore structure, defined in SDL_sem.c */ |
80 struct SDL_semaphore; | 86 struct SDL_semaphore; |
81 typedef struct SDL_semaphore SDL_sem; | 87 typedef struct SDL_semaphore SDL_sem; |
82 | 88 |
83 /* Create a semaphore, initialized with value, returns NULL on failure. */ | 89 /** Create a semaphore, initialized with value, returns NULL on failure. */ |
84 extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); | 90 extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); |
85 | 91 |
86 /* Destroy a semaphore */ | 92 /** Destroy a semaphore */ |
87 extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); | 93 extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); |
88 | 94 |
89 /* This function suspends the calling thread until the semaphore pointed | 95 /** |
96 * This function suspends the calling thread until the semaphore pointed | |
90 * to by sem has a positive count. It then atomically decreases the semaphore | 97 * to by sem has a positive count. It then atomically decreases the semaphore |
91 * count. | 98 * count. |
92 */ | 99 */ |
93 extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); | 100 extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); |
94 | 101 |
95 /* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds, | 102 /** Non-blocking variant of SDL_SemWait(). |
96 SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. | 103 * @return 0 if the wait succeeds, |
97 */ | 104 * SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. |
105 */ | |
98 extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); | 106 extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); |
99 | 107 |
100 /* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if | 108 /** Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if |
101 the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in | 109 * the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in |
102 the allotted time, and -1 on error. | 110 * the allotted time, and -1 on error. |
103 On some platforms this function is implemented by looping with a delay | 111 * |
104 of 1 ms, and so should be avoided if possible. | 112 * On some platforms this function is implemented by looping with a delay |
105 */ | 113 * of 1 ms, and so should be avoided if possible. |
114 */ | |
106 extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); | 115 extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); |
107 | 116 |
108 /* Atomically increases the semaphore's count (not blocking), returns 0, | 117 /** Atomically increases the semaphore's count (not blocking). |
109 or -1 on error. | 118 * @return 0, or -1 on error. |
110 */ | 119 */ |
111 extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); | 120 extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); |
112 | 121 |
113 /* Returns the current count of the semaphore */ | 122 /** Returns the current count of the semaphore */ |
114 extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); | 123 extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); |
115 | 124 |
125 /*@}*/ | |
116 | 126 |
117 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 127 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
118 /* Condition variable functions */ | 128 /** @name Condition_variable_functions */ /*@{*/ |
119 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 129 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
120 | 130 |
121 /* The SDL condition variable structure, defined in SDL_cond.c */ | 131 /*@{*/ |
132 /** The SDL condition variable structure, defined in SDL_cond.c */ | |
122 struct SDL_cond; | 133 struct SDL_cond; |
123 typedef struct SDL_cond SDL_cond; | 134 typedef struct SDL_cond SDL_cond; |
135 /*@}*/ | |
124 | 136 |
125 /* Create a condition variable */ | 137 /** Create a condition variable */ |
126 extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); | 138 extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); |
127 | 139 |
128 /* Destroy a condition variable */ | 140 /** Destroy a condition variable */ |
129 extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); | 141 extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); |
130 | 142 |
131 /* Restart one of the threads that are waiting on the condition variable, | 143 /** Restart one of the threads that are waiting on the condition variable, |
132 returns 0 or -1 on error. | 144 * @return 0 or -1 on error. |
133 */ | 145 */ |
134 extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); | 146 extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); |
135 | 147 |
136 /* Restart all threads that are waiting on the condition variable, | 148 /** Restart all threads that are waiting on the condition variable, |
137 returns 0 or -1 on error. | 149 * @return 0 or -1 on error. |
138 */ | 150 */ |
139 extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); | 151 extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); |
140 | 152 |
141 /* Wait on the condition variable, unlocking the provided mutex. | 153 /** Wait on the condition variable, unlocking the provided mutex. |
142 The mutex must be locked before entering this function! | 154 * The mutex must be locked before entering this function! |
143 The mutex is re-locked once the condition variable is signaled. | 155 * The mutex is re-locked once the condition variable is signaled. |
144 Returns 0 when it is signaled, or -1 on error. | 156 * @return 0 when it is signaled, or -1 on error. |
145 */ | 157 */ |
146 extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); | 158 extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); |
147 | 159 |
148 /* Waits for at most 'ms' milliseconds, and returns 0 if the condition | 160 /** Waits for at most 'ms' milliseconds, and returns 0 if the condition |
149 variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not | 161 * variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not |
150 signaled in the allotted time, and -1 on error. | 162 * signaled in the allotted time, and -1 on error. |
151 On some platforms this function is implemented by looping with a delay | 163 * On some platforms this function is implemented by looping with a delay |
152 of 1 ms, and so should be avoided if possible. | 164 * of 1 ms, and so should be avoided if possible. |
153 */ | 165 */ |
154 extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); | 166 extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); |
167 | |
168 /*@}*/ | |
155 | 169 |
156 /* Ends C function definitions when using C++ */ | 170 /* Ends C function definitions when using C++ */ |
157 #ifdef __cplusplus | 171 #ifdef __cplusplus |
158 } | 172 } |
159 #endif | 173 #endif |
160 #include "close_code.h" | 174 #include "close_code.h" |
161 | 175 |
162 #endif /* _SDL_mutex_h */ | 176 #endif /* _SDL_mutex_h */ |
177 |