0
|
1 <HTML
|
|
2 ><HEAD
|
|
3 ><TITLE
|
|
4 >SDL_CreateMutex</TITLE
|
|
5 ><META
|
|
6 NAME="GENERATOR"
|
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.61
|
|
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_KillThread"
|
|
17 HREF="sdlkillthread.html"><LINK
|
|
18 REL="NEXT"
|
|
19 TITLE="SDL_DestroyMutex"
|
|
20 HREF="sdldestroymutex.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="sdlkillthread.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="sdldestroymutex.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="SDLCREATEMUTEX"
|
|
71 >SDL_CreateMutex</A
|
|
72 ></H1
|
|
73 ><DIV
|
|
74 CLASS="REFNAMEDIV"
|
|
75 ><A
|
|
76 NAME="AEN7195"
|
|
77 ></A
|
|
78 ><H2
|
|
79 >Name</H2
|
|
80 >SDL_CreateMutex -- Create a mutex</DIV
|
|
81 ><DIV
|
|
82 CLASS="REFSYNOPSISDIV"
|
|
83 ><A
|
|
84 NAME="AEN7198"
|
|
85 ></A
|
|
86 ><H2
|
|
87 >Synopsis</H2
|
|
88 ><DIV
|
|
89 CLASS="FUNCSYNOPSIS"
|
|
90 ><A
|
|
91 NAME="AEN7199"
|
|
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 >SDL_mutex *<B
|
|
104 CLASS="FSFUNC"
|
|
105 >SDL_CreateMutex</B
|
|
106 ></CODE
|
|
107 >(void);</CODE
|
|
108 ></P
|
|
109 ><P
|
|
110 ></P
|
|
111 ></DIV
|
|
112 ></DIV
|
|
113 ><DIV
|
|
114 CLASS="REFSECT1"
|
|
115 ><A
|
|
116 NAME="AEN7205"
|
|
117 ></A
|
|
118 ><H2
|
|
119 >Description</H2
|
|
120 ><P
|
|
121 >Create a new, unlocked mutex.</P
|
|
122 ></DIV
|
|
123 ><DIV
|
|
124 CLASS="REFSECT1"
|
|
125 ><A
|
|
126 NAME="AEN7208"
|
|
127 ></A
|
|
128 ><H2
|
|
129 >Examples</H2
|
|
130 ><PRE
|
|
131 CLASS="PROGRAMLISTING"
|
|
132 >SDL_mutex *mut;
|
|
133
|
|
134 mut=SDL_CreateMutex();
|
|
135 .
|
|
136 .
|
|
137 if(SDL_mutexP(mut)==-1){
|
|
138 fprintf(stderr, "Couldn't lock mutex\n");
|
|
139 exit(-1);
|
|
140 }
|
|
141 .
|
|
142 /* Do stuff while mutex is locked */
|
|
143 .
|
|
144 .
|
|
145 if(SDL_mutexV(mut)==-1){
|
|
146 fprintf(stderr, "Couldn't unlock mutex\n");
|
|
147 exit(-1);
|
|
148 }
|
|
149
|
|
150 SDL_DestroyMutex(mut); </PRE
|
|
151 ></DIV
|
|
152 ><DIV
|
|
153 CLASS="REFSECT1"
|
|
154 ><A
|
|
155 NAME="AEN7211"
|
|
156 ></A
|
|
157 ><H2
|
|
158 >See Also</H2
|
|
159 ><P
|
|
160 ><A
|
|
161 HREF="sdlmutexp.html"
|
|
162 ><TT
|
|
163 CLASS="FUNCTION"
|
|
164 >SDL_mutexP</TT
|
|
165 ></A
|
|
166 >,
|
|
167 <A
|
|
168 HREF="sdlmutexv.html"
|
|
169 ><TT
|
|
170 CLASS="FUNCTION"
|
|
171 >SDL_mutexV</TT
|
|
172 ></A
|
|
173 >,
|
|
174 <A
|
|
175 HREF="sdldestroymutex.html"
|
|
176 ><TT
|
|
177 CLASS="FUNCTION"
|
|
178 >SDL_DestroyMutex</TT
|
|
179 ></A
|
|
180 ></P
|
|
181 ></DIV
|
|
182 ><DIV
|
|
183 CLASS="NAVFOOTER"
|
|
184 ><HR
|
|
185 ALIGN="LEFT"
|
|
186 WIDTH="100%"><TABLE
|
|
187 WIDTH="100%"
|
|
188 BORDER="0"
|
|
189 CELLPADDING="0"
|
|
190 CELLSPACING="0"
|
|
191 ><TR
|
|
192 ><TD
|
|
193 WIDTH="33%"
|
|
194 ALIGN="left"
|
|
195 VALIGN="top"
|
|
196 ><A
|
|
197 HREF="sdlkillthread.html"
|
|
198 >Prev</A
|
|
199 ></TD
|
|
200 ><TD
|
|
201 WIDTH="34%"
|
|
202 ALIGN="center"
|
|
203 VALIGN="top"
|
|
204 ><A
|
|
205 HREF="index.html"
|
|
206 >Home</A
|
|
207 ></TD
|
|
208 ><TD
|
|
209 WIDTH="33%"
|
|
210 ALIGN="right"
|
|
211 VALIGN="top"
|
|
212 ><A
|
|
213 HREF="sdldestroymutex.html"
|
|
214 >Next</A
|
|
215 ></TD
|
|
216 ></TR
|
|
217 ><TR
|
|
218 ><TD
|
|
219 WIDTH="33%"
|
|
220 ALIGN="left"
|
|
221 VALIGN="top"
|
|
222 >SDL_KillThread</TD
|
|
223 ><TD
|
|
224 WIDTH="34%"
|
|
225 ALIGN="center"
|
|
226 VALIGN="top"
|
|
227 ><A
|
|
228 HREF="thread.html"
|
|
229 >Up</A
|
|
230 ></TD
|
|
231 ><TD
|
|
232 WIDTH="33%"
|
|
233 ALIGN="right"
|
|
234 VALIGN="top"
|
|
235 >SDL_DestroyMutex</TD
|
|
236 ></TR
|
|
237 ></TABLE
|
|
238 ></DIV
|
|
239 ></BODY
|
|
240 ></HTML
|
|
241 > |