Mercurial > sdl-ios-xcode
annotate docs/html/sdlsemtrywait.html @ 225:2d1753bc178a
Fixed building hermes objects with automake 1.5 (thanks winterlion)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 02 Nov 2001 19:59:41 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >SDL_SemTryWait</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="Multi-threaded Programming" | |
14 HREF="thread.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_SemWait" | |
17 HREF="sdlsemwait.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_SemWaitTimeout" | |
20 HREF="sdlsemwaittimeout.html"></HEAD | |
21 ><BODY | |
22 CLASS="REFENTRY" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 WIDTH="100%" | |
32 BORDER="0" | |
33 CELLPADDING="0" | |
34 CELLSPACING="0" | |
35 ><TR | |
36 ><TH | |
37 COLSPAN="3" | |
38 ALIGN="center" | |
39 >SDL Library Documentation</TH | |
40 ></TR | |
41 ><TR | |
42 ><TD | |
43 WIDTH="10%" | |
44 ALIGN="left" | |
45 VALIGN="bottom" | |
46 ><A | |
47 HREF="sdlsemwait.html" | |
48 >Prev</A | |
49 ></TD | |
50 ><TD | |
51 WIDTH="80%" | |
52 ALIGN="center" | |
53 VALIGN="bottom" | |
54 ></TD | |
55 ><TD | |
56 WIDTH="10%" | |
57 ALIGN="right" | |
58 VALIGN="bottom" | |
59 ><A | |
60 HREF="sdlsemwaittimeout.html" | |
61 >Next</A | |
62 ></TD | |
63 ></TR | |
64 ></TABLE | |
65 ><HR | |
66 ALIGN="LEFT" | |
67 WIDTH="100%"></DIV | |
68 ><H1 | |
69 ><A | |
70 NAME="SDLSEMTRYWAIT" | |
71 >SDL_SemTryWait</A | |
72 ></H1 | |
73 ><DIV | |
74 CLASS="REFNAMEDIV" | |
75 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
76 NAME="AEN7681" |
0 | 77 ></A |
78 ><H2 | |
79 >Name</H2 | |
80 >SDL_SemTryWait -- Attempt to lock a semaphore but don't suspend the thread.</DIV | |
81 ><DIV | |
82 CLASS="REFSYNOPSISDIV" | |
83 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
84 NAME="AEN7684" |
0 | 85 ></A |
86 ><H2 | |
87 >Synopsis</H2 | |
88 ><DIV | |
89 CLASS="FUNCSYNOPSIS" | |
90 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
91 NAME="AEN7685" |
0 | 92 ></A |
93 ><P | |
94 ></P | |
95 ><PRE | |
96 CLASS="FUNCSYNOPSISINFO" | |
97 >#include "SDL.h" | |
98 #include "SDL_thread.h"</PRE | |
99 ><P | |
100 ><CODE | |
101 ><CODE | |
102 CLASS="FUNCDEF" | |
103 >int <B | |
104 CLASS="FSFUNC" | |
105 >SDL_SemTryWait</B | |
106 ></CODE | |
107 >(SDL_sem *sem);</CODE | |
108 ></P | |
109 ><P | |
110 ></P | |
111 ></DIV | |
112 ></DIV | |
113 ><DIV | |
114 CLASS="REFSECT1" | |
115 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
116 NAME="AEN7691" |
0 | 117 ></A |
118 ><H2 | |
119 >Description</H2 | |
120 ><P | |
121 ><TT | |
122 CLASS="FUNCTION" | |
123 >SDL_SemTryWait</TT | |
124 > is a non-blocking varient of | |
125 <A | |
126 HREF="sdlsemwait.html" | |
127 ><TT | |
128 CLASS="FUNCTION" | |
129 >SDL_SemWait</TT | |
130 ></A | |
131 >. If the value of the semaphore | |
132 pointed to by <TT | |
133 CLASS="PARAMETER" | |
134 ><I | |
135 >sem</I | |
136 ></TT | |
137 > is positive it will atomically | |
138 decrement the semaphore value and return 0, otherwise it will return | |
139 <SPAN | |
140 CLASS="RETURNVALUE" | |
141 >SDL_MUTEX_TIMEOUT</SPAN | |
142 > instead of suspending the thread.</P | |
143 ><P | |
144 >After <TT | |
145 CLASS="FUNCTION" | |
146 >SDL_SemTryWait</TT | |
147 > is successful, the semaphore | |
148 can be released and its count atomically incremented by a successful call to | |
149 <A | |
150 HREF="sdlsempost.html" | |
151 >SDL_SemPost</A | |
152 >.</P | |
153 ></DIV | |
154 ><DIV | |
155 CLASS="REFSECT1" | |
156 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
157 NAME="AEN7702" |
0 | 158 ></A |
159 ><H2 | |
160 >Return Value</H2 | |
161 ><P | |
162 >Returns <SPAN | |
163 CLASS="RETURNVALUE" | |
164 >0</SPAN | |
165 > if the semaphore was successfully locked or | |
166 either <SPAN | |
167 CLASS="RETURNVALUE" | |
168 >SDL_MUTEX_TIMEOUT</SPAN | |
169 > or <SPAN | |
170 CLASS="RETURNVALUE" | |
171 >-1</SPAN | |
172 > | |
173 if the thread would have suspended or there was an error, respectivly.</P | |
174 ><P | |
175 >If the semaphore was not successfully locked, the semaphore will be unchanged.</P | |
176 ></DIV | |
177 ><DIV | |
178 CLASS="REFSECT1" | |
179 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
180 NAME="AEN7709" |
0 | 181 ></A |
182 ><H2 | |
183 >Examples</H2 | |
184 ><P | |
185 ><PRE | |
186 CLASS="PROGRAMLISTING" | |
187 >res = SDL_SemTryWait(my_sem); | |
188 | |
189 if (res == SDL_MUTEX_TIMEOUT) { | |
190 return TRY_AGAIN; | |
191 } | |
192 if (res == -1) { | |
193 return WAIT_ERROR; | |
194 } | |
195 | |
196 ... | |
197 | |
198 SDL_SemPost(my_sem);</PRE | |
199 ></P | |
200 ></DIV | |
201 ><DIV | |
202 CLASS="REFSECT1" | |
203 ><A | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
204 NAME="AEN7713" |
0 | 205 ></A |
206 ><H2 | |
207 >See Also</H2 | |
208 ><P | |
209 ><A | |
210 HREF="sdlcreatesemaphore.html" | |
211 ><TT | |
212 CLASS="FUNCTION" | |
213 >SDL_CreateSemaphore</TT | |
214 ></A | |
215 >, | |
216 <A | |
217 HREF="sdldestroysemaphore.html" | |
218 ><TT | |
219 CLASS="FUNCTION" | |
220 >SDL_DestroySemaphore</TT | |
221 ></A | |
222 >, | |
223 <A | |
224 HREF="sdlsemwait.html" | |
225 ><TT | |
226 CLASS="FUNCTION" | |
227 >SDL_SemWait</TT | |
228 ></A | |
229 >, | |
230 <A | |
231 HREF="sdlsemwaittimeout.html" | |
232 ><TT | |
233 CLASS="FUNCTION" | |
234 >SDL_SemWaitTimeout</TT | |
235 ></A | |
236 >, | |
237 <A | |
238 HREF="sdlsempost.html" | |
239 ><TT | |
240 CLASS="FUNCTION" | |
241 >SDL_SemPost</TT | |
242 ></A | |
243 >, | |
244 <A | |
245 HREF="sdlsemvalue.html" | |
246 ><TT | |
247 CLASS="FUNCTION" | |
248 >SDL_SemValue</TT | |
249 ></A | |
250 ></P | |
251 ></DIV | |
252 ><DIV | |
253 CLASS="NAVFOOTER" | |
254 ><HR | |
255 ALIGN="LEFT" | |
256 WIDTH="100%"><TABLE | |
257 WIDTH="100%" | |
258 BORDER="0" | |
259 CELLPADDING="0" | |
260 CELLSPACING="0" | |
261 ><TR | |
262 ><TD | |
263 WIDTH="33%" | |
264 ALIGN="left" | |
265 VALIGN="top" | |
266 ><A | |
267 HREF="sdlsemwait.html" | |
268 >Prev</A | |
269 ></TD | |
270 ><TD | |
271 WIDTH="34%" | |
272 ALIGN="center" | |
273 VALIGN="top" | |
274 ><A | |
275 HREF="index.html" | |
276 >Home</A | |
277 ></TD | |
278 ><TD | |
279 WIDTH="33%" | |
280 ALIGN="right" | |
281 VALIGN="top" | |
282 ><A | |
283 HREF="sdlsemwaittimeout.html" | |
284 >Next</A | |
285 ></TD | |
286 ></TR | |
287 ><TR | |
288 ><TD | |
289 WIDTH="33%" | |
290 ALIGN="left" | |
291 VALIGN="top" | |
292 >SDL_SemWait</TD | |
293 ><TD | |
294 WIDTH="34%" | |
295 ALIGN="center" | |
296 VALIGN="top" | |
297 ><A | |
298 HREF="thread.html" | |
299 >Up</A | |
300 ></TD | |
301 ><TD | |
302 WIDTH="33%" | |
303 ALIGN="right" | |
304 VALIGN="top" | |
305 >SDL_SemWaitTimeout</TD | |
306 ></TR | |
307 ></TABLE | |
308 ></DIV | |
309 ></BODY | |
310 ></HTML | |
311 > |