Imported Upstream version 2.50.2
[platform/upstream/glib.git] / docs / reference / glib / html / glib-Asynchronous-Queues.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Asynchronous Queues: GLib Reference Manual</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7 <link rel="home" href="index.html" title="GLib Reference Manual">
8 <link rel="up" href="glib-core.html" title="GLib Core Application Support">
9 <link rel="prev" href="glib-Thread-Pools.html" title="Thread Pools">
10 <link rel="next" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules">
11 <meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
16 <td width="100%" align="left" class="shortcuts">
17 <a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
18                   <a href="#glib-Asynchronous-Queues.description" class="shortcut">Description</a></span>
19 </td>
20 <td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
21 <td><a accesskey="u" href="glib-core.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
22 <td><a accesskey="p" href="glib-Thread-Pools.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
23 <td><a accesskey="n" href="glib-Dynamic-Loading-of-Modules.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
24 </tr></table>
25 <div class="refentry">
26 <a name="glib-Asynchronous-Queues"></a><div class="titlepage"></div>
27 <div class="refnamediv"><table width="100%"><tr>
28 <td valign="top">
29 <h2><span class="refentrytitle"><a name="glib-Asynchronous-Queues.top_of_page"></a>Asynchronous Queues</span></h2>
30 <p>Asynchronous Queues — asynchronous communication between threads</p>
31 </td>
32 <td class="gallery_image" valign="top" align="right"></td>
33 </tr></table></div>
34 <div class="refsect1">
35 <a name="glib-Asynchronous-Queues.functions"></a><h2>Functions</h2>
36 <div class="informaltable"><table class="informaltable" width="100%" border="0">
37 <colgroup>
38 <col width="150px" class="functions_return">
39 <col class="functions_name">
40 </colgroup>
41 <tbody>
42 <tr>
43 <td class="function_type">
44 <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="returnvalue">GAsyncQueue</span></a> *
45 </td>
46 <td class="function_name">
47 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-new" title="g_async_queue_new ()">g_async_queue_new</a> <span class="c_punctuation">()</span>
48 </td>
49 </tr>
50 <tr>
51 <td class="function_type">
52 <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="returnvalue">GAsyncQueue</span></a> *
53 </td>
54 <td class="function_name">
55 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-new-full" title="g_async_queue_new_full ()">g_async_queue_new_full</a> <span class="c_punctuation">()</span>
56 </td>
57 </tr>
58 <tr>
59 <td class="function_type">
60 <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="returnvalue">GAsyncQueue</span></a> *
61 </td>
62 <td class="function_name">
63 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref" title="g_async_queue_ref ()">g_async_queue_ref</a> <span class="c_punctuation">()</span>
64 </td>
65 </tr>
66 <tr>
67 <td class="function_type">
68 <span class="returnvalue">void</span>
69 </td>
70 <td class="function_name">
71 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref" title="g_async_queue_unref ()">g_async_queue_unref</a> <span class="c_punctuation">()</span>
72 </td>
73 </tr>
74 <tr>
75 <td class="function_type">
76 <span class="returnvalue">void</span>
77 </td>
78 <td class="function_name">
79 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push" title="g_async_queue_push ()">g_async_queue_push</a> <span class="c_punctuation">()</span>
80 </td>
81 </tr>
82 <tr>
83 <td class="function_type">
84 <span class="returnvalue">void</span>
85 </td>
86 <td class="function_name">
87 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-sorted" title="g_async_queue_push_sorted ()">g_async_queue_push_sorted</a> <span class="c_punctuation">()</span>
88 </td>
89 </tr>
90 <tr>
91 <td class="function_type">
92 <span class="returnvalue">void</span>
93 </td>
94 <td class="function_name">
95 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-front" title="g_async_queue_push_front ()">g_async_queue_push_front</a> <span class="c_punctuation">()</span>
96 </td>
97 </tr>
98 <tr>
99 <td class="function_type">
100 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
101 </td>
102 <td class="function_name">
103 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-remove" title="g_async_queue_remove ()">g_async_queue_remove</a> <span class="c_punctuation">()</span>
104 </td>
105 </tr>
106 <tr>
107 <td class="function_type">
108 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
109 </td>
110 <td class="function_name">
111 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-pop" title="g_async_queue_pop ()">g_async_queue_pop</a> <span class="c_punctuation">()</span>
112 </td>
113 </tr>
114 <tr>
115 <td class="function_type">
116 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
117 </td>
118 <td class="function_name">
119 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-try-pop" title="g_async_queue_try_pop ()">g_async_queue_try_pop</a> <span class="c_punctuation">()</span>
120 </td>
121 </tr>
122 <tr>
123 <td class="function_type">
124 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
125 </td>
126 <td class="function_name">
127 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timeout-pop" title="g_async_queue_timeout_pop ()">g_async_queue_timeout_pop</a> <span class="c_punctuation">()</span>
128 </td>
129 </tr>
130 <tr>
131 <td class="function_type">
132 <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
133 </td>
134 <td class="function_name">
135 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-length" title="g_async_queue_length ()">g_async_queue_length</a> <span class="c_punctuation">()</span>
136 </td>
137 </tr>
138 <tr>
139 <td class="function_type">
140 <span class="returnvalue">void</span>
141 </td>
142 <td class="function_name">
143 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort" title="g_async_queue_sort ()">g_async_queue_sort</a> <span class="c_punctuation">()</span>
144 </td>
145 </tr>
146 <tr>
147 <td class="function_type">
148 <span class="returnvalue">void</span>
149 </td>
150 <td class="function_name">
151 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-lock" title="g_async_queue_lock ()">g_async_queue_lock</a> <span class="c_punctuation">()</span>
152 </td>
153 </tr>
154 <tr>
155 <td class="function_type">
156 <span class="returnvalue">void</span>
157 </td>
158 <td class="function_name">
159 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unlock" title="g_async_queue_unlock ()">g_async_queue_unlock</a> <span class="c_punctuation">()</span>
160 </td>
161 </tr>
162 <tr>
163 <td class="function_type">
164 <span class="returnvalue">void</span>
165 </td>
166 <td class="function_name">
167 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref-unlocked" title="g_async_queue_ref_unlocked ()">g_async_queue_ref_unlocked</a> <span class="c_punctuation">()</span>
168 </td>
169 </tr>
170 <tr>
171 <td class="function_type">
172 <span class="returnvalue">void</span>
173 </td>
174 <td class="function_name">
175 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref-and-unlock" title="g_async_queue_unref_and_unlock ()">g_async_queue_unref_and_unlock</a> <span class="c_punctuation">()</span>
176 </td>
177 </tr>
178 <tr>
179 <td class="function_type">
180 <span class="returnvalue">void</span>
181 </td>
182 <td class="function_name">
183 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-unlocked" title="g_async_queue_push_unlocked ()">g_async_queue_push_unlocked</a> <span class="c_punctuation">()</span>
184 </td>
185 </tr>
186 <tr>
187 <td class="function_type">
188 <span class="returnvalue">void</span>
189 </td>
190 <td class="function_name">
191 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-sorted-unlocked" title="g_async_queue_push_sorted_unlocked ()">g_async_queue_push_sorted_unlocked</a> <span class="c_punctuation">()</span>
192 </td>
193 </tr>
194 <tr>
195 <td class="function_type">
196 <span class="returnvalue">void</span>
197 </td>
198 <td class="function_name">
199 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-front-unlocked" title="g_async_queue_push_front_unlocked ()">g_async_queue_push_front_unlocked</a> <span class="c_punctuation">()</span>
200 </td>
201 </tr>
202 <tr>
203 <td class="function_type">
204 <a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
205 </td>
206 <td class="function_name">
207 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-remove-unlocked" title="g_async_queue_remove_unlocked ()">g_async_queue_remove_unlocked</a> <span class="c_punctuation">()</span>
208 </td>
209 </tr>
210 <tr>
211 <td class="function_type">
212 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
213 </td>
214 <td class="function_name">
215 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-pop-unlocked" title="g_async_queue_pop_unlocked ()">g_async_queue_pop_unlocked</a> <span class="c_punctuation">()</span>
216 </td>
217 </tr>
218 <tr>
219 <td class="function_type">
220 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
221 </td>
222 <td class="function_name">
223 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-try-pop-unlocked" title="g_async_queue_try_pop_unlocked ()">g_async_queue_try_pop_unlocked</a> <span class="c_punctuation">()</span>
224 </td>
225 </tr>
226 <tr>
227 <td class="function_type">
228 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
229 </td>
230 <td class="function_name">
231 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timeout-pop-unlocked" title="g_async_queue_timeout_pop_unlocked ()">g_async_queue_timeout_pop_unlocked</a> <span class="c_punctuation">()</span>
232 </td>
233 </tr>
234 <tr>
235 <td class="function_type">
236 <a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
237 </td>
238 <td class="function_name">
239 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-length-unlocked" title="g_async_queue_length_unlocked ()">g_async_queue_length_unlocked</a> <span class="c_punctuation">()</span>
240 </td>
241 </tr>
242 <tr>
243 <td class="function_type">
244 <span class="returnvalue">void</span>
245 </td>
246 <td class="function_name">
247 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort-unlocked" title="g_async_queue_sort_unlocked ()">g_async_queue_sort_unlocked</a> <span class="c_punctuation">()</span>
248 </td>
249 </tr>
250 <tr>
251 <td class="function_type">
252 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
253 </td>
254 <td class="function_name">
255 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timed-pop" title="g_async_queue_timed_pop ()">g_async_queue_timed_pop</a> <span class="c_punctuation">()</span>
256 </td>
257 </tr>
258 <tr>
259 <td class="function_type">
260 <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
261 </td>
262 <td class="function_name">
263 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timed-pop-unlocked" title="g_async_queue_timed_pop_unlocked ()">g_async_queue_timed_pop_unlocked</a> <span class="c_punctuation">()</span>
264 </td>
265 </tr>
266 </tbody>
267 </table></div>
268 </div>
269 <div class="refsect1">
270 <a name="glib-Asynchronous-Queues.other"></a><h2>Types and Values</h2>
271 <div class="informaltable"><table class="informaltable" width="100%" border="0">
272 <colgroup>
273 <col width="150px" class="name">
274 <col class="description">
275 </colgroup>
276 <tbody><tr>
277 <td class="datatype_keyword"> </td>
278 <td class="function_name"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue">GAsyncQueue</a></td>
279 </tr></tbody>
280 </table></div>
281 </div>
282 <div class="refsect1">
283 <a name="glib-Asynchronous-Queues.includes"></a><h2>Includes</h2>
284 <pre class="synopsis">#include &lt;glib.h&gt;
285 </pre>
286 </div>
287 <div class="refsect1">
288 <a name="glib-Asynchronous-Queues.description"></a><h2>Description</h2>
289 <p>Often you need to communicate between different threads. In general
290 it's safer not to do this by shared memory, but by explicit message
291 passing. These messages only make sense asynchronously for
292 multi-threaded applications though, as a synchronous operation could
293 as well be done in the same thread.</p>
294 <p>Asynchronous queues are an exception from most other GLib data
295 structures, as they can be used simultaneously from multiple threads
296 without explicit locking and they bring their own builtin reference
297 counting. This is because the nature of an asynchronous queue is that
298 it will always be used by at least 2 concurrent threads.</p>
299 <p>For using an asynchronous queue you first have to create one with
300 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-new" title="g_async_queue_new ()"><code class="function">g_async_queue_new()</code></a>. <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> structs are reference counted,
301 use <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref" title="g_async_queue_ref ()"><code class="function">g_async_queue_ref()</code></a> and <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref" title="g_async_queue_unref ()"><code class="function">g_async_queue_unref()</code></a> to manage your
302 references.</p>
303 <p>A thread which wants to send a message to that queue simply calls
304 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push" title="g_async_queue_push ()"><code class="function">g_async_queue_push()</code></a> to push the message to the queue.</p>
305 <p>A thread which is expecting messages from an asynchronous queue
306 simply calls <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-pop" title="g_async_queue_pop ()"><code class="function">g_async_queue_pop()</code></a> for that queue. If no message is
307 available in the queue at that point, the thread is now put to sleep
308 until a message arrives. The message will be removed from the queue
309 and returned. The functions <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-try-pop" title="g_async_queue_try_pop ()"><code class="function">g_async_queue_try_pop()</code></a> and
310 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timeout-pop" title="g_async_queue_timeout_pop ()"><code class="function">g_async_queue_timeout_pop()</code></a> can be used to only check for the presence
311 of messages or to only wait a certain time for messages respectively.</p>
312 <p>For almost every function there exist two variants, one that locks
313 the queue and one that doesn't. That way you can hold the queue lock
314 (acquire it with <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-lock" title="g_async_queue_lock ()"><code class="function">g_async_queue_lock()</code></a> and release it with
315 <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unlock" title="g_async_queue_unlock ()"><code class="function">g_async_queue_unlock()</code></a>) over multiple queue accessing instructions.
316 This can be necessary to ensure the integrity of the queue, but should
317 only be used when really necessary, as it can make your life harder
318 if used unwisely. Normally you should only use the locking function
319 variants (those without the _unlocked suffix).</p>
320 <p>In many cases, it may be more convenient to use <a class="link" href="glib-Thread-Pools.html#GThreadPool" title="struct GThreadPool"><span class="type">GThreadPool</span></a> when
321 you need to distribute work to a set of worker threads instead of
322 using <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> manually. <a class="link" href="glib-Thread-Pools.html#GThreadPool" title="struct GThreadPool"><span class="type">GThreadPool</span></a> uses a GAsyncQueue
323 internally.</p>
324 </div>
325 <div class="refsect1">
326 <a name="glib-Asynchronous-Queues.functions_details"></a><h2>Functions</h2>
327 <div class="refsect2">
328 <a name="g-async-queue-new"></a><h3>g_async_queue_new ()</h3>
329 <pre class="programlisting"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="returnvalue">GAsyncQueue</span></a> *
330 g_async_queue_new (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
331 <p>Creates a new asynchronous queue.</p>
332 <div class="refsect3">
333 <a name="g-async-queue-new.returns"></a><h4>Returns</h4>
334 <p> a new <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a>. Free with <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref" title="g_async_queue_unref ()"><code class="function">g_async_queue_unref()</code></a></p>
335 </div>
336 </div>
337 <hr>
338 <div class="refsect2">
339 <a name="g-async-queue-new-full"></a><h3>g_async_queue_new_full ()</h3>
340 <pre class="programlisting"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="returnvalue">GAsyncQueue</span></a> *
341 g_async_queue_new_full (<em class="parameter"><code><a class="link" href="glib-Datasets.html#GDestroyNotify" title="GDestroyNotify ()"><span class="type">GDestroyNotify</span></a> item_free_func</code></em>);</pre>
342 <p>Creates a new asynchronous queue and sets up a destroy notify
343 function that is used to free any remaining queue items when
344 the queue is destroyed after the final unref.</p>
345 <div class="refsect3">
346 <a name="g-async-queue-new-full.parameters"></a><h4>Parameters</h4>
347 <div class="informaltable"><table class="informaltable" width="100%" border="0">
348 <colgroup>
349 <col width="150px" class="parameters_name">
350 <col class="parameters_description">
351 <col width="200px" class="parameters_annotations">
352 </colgroup>
353 <tbody><tr>
354 <td class="parameter_name"><p>item_free_func</p></td>
355 <td class="parameter_description"><p>function to free queue elements</p></td>
356 <td class="parameter_annotations"> </td>
357 </tr></tbody>
358 </table></div>
359 </div>
360 <div class="refsect3">
361 <a name="g-async-queue-new-full.returns"></a><h4>Returns</h4>
362 <p> a new <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a>. Free with <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref" title="g_async_queue_unref ()"><code class="function">g_async_queue_unref()</code></a></p>
363 </div>
364 <p class="since">Since: <a class="link" href="api-index-2-16.html#api-index-2.16">2.16</a></p>
365 </div>
366 <hr>
367 <div class="refsect2">
368 <a name="g-async-queue-ref"></a><h3>g_async_queue_ref ()</h3>
369 <pre class="programlisting"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="returnvalue">GAsyncQueue</span></a> *
370 g_async_queue_ref (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
371 <p>Increases the reference count of the asynchronous <em class="parameter"><code>queue</code></em>
372  by 1.
373 You do not need to hold the lock to call this function.</p>
374 <div class="refsect3">
375 <a name="g-async-queue-ref.parameters"></a><h4>Parameters</h4>
376 <div class="informaltable"><table class="informaltable" width="100%" border="0">
377 <colgroup>
378 <col width="150px" class="parameters_name">
379 <col class="parameters_description">
380 <col width="200px" class="parameters_annotations">
381 </colgroup>
382 <tbody><tr>
383 <td class="parameter_name"><p>queue</p></td>
384 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
385 <td class="parameter_annotations"> </td>
386 </tr></tbody>
387 </table></div>
388 </div>
389 <div class="refsect3">
390 <a name="g-async-queue-ref.returns"></a><h4>Returns</h4>
391 <p> the <em class="parameter"><code>queue</code></em>
392 that was passed in (since 2.6)</p>
393 </div>
394 </div>
395 <hr>
396 <div class="refsect2">
397 <a name="g-async-queue-unref"></a><h3>g_async_queue_unref ()</h3>
398 <pre class="programlisting"><span class="returnvalue">void</span>
399 g_async_queue_unref (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
400 <p>Decreases the reference count of the asynchronous <em class="parameter"><code>queue</code></em>
401  by 1.</p>
402 <p>If the reference count went to 0, the <em class="parameter"><code>queue</code></em>
403  will be destroyed
404 and the memory allocated will be freed. So you are not allowed
405 to use the <em class="parameter"><code>queue</code></em>
406  afterwards, as it might have disappeared.
407 You do not need to hold the lock to call this function.</p>
408 <div class="refsect3">
409 <a name="g-async-queue-unref.parameters"></a><h4>Parameters</h4>
410 <div class="informaltable"><table class="informaltable" width="100%" border="0">
411 <colgroup>
412 <col width="150px" class="parameters_name">
413 <col class="parameters_description">
414 <col width="200px" class="parameters_annotations">
415 </colgroup>
416 <tbody><tr>
417 <td class="parameter_name"><p>queue</p></td>
418 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</p></td>
419 <td class="parameter_annotations"> </td>
420 </tr></tbody>
421 </table></div>
422 </div>
423 </div>
424 <hr>
425 <div class="refsect2">
426 <a name="g-async-queue-push"></a><h3>g_async_queue_push ()</h3>
427 <pre class="programlisting"><span class="returnvalue">void</span>
428 g_async_queue_push (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
429                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
430 <p>Pushes the <em class="parameter"><code>data</code></em>
431  into the <em class="parameter"><code>queue</code></em>
432 . <em class="parameter"><code>data</code></em>
433  must not be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
434 <div class="refsect3">
435 <a name="g-async-queue-push.parameters"></a><h4>Parameters</h4>
436 <div class="informaltable"><table class="informaltable" width="100%" border="0">
437 <colgroup>
438 <col width="150px" class="parameters_name">
439 <col class="parameters_description">
440 <col width="200px" class="parameters_annotations">
441 </colgroup>
442 <tbody>
443 <tr>
444 <td class="parameter_name"><p>queue</p></td>
445 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
446 <td class="parameter_annotations"> </td>
447 </tr>
448 <tr>
449 <td class="parameter_name"><p>data</p></td>
450 <td class="parameter_description"><p><em class="parameter"><code>data</code></em>
451 to push into the <em class="parameter"><code>queue</code></em>
452 </p></td>
453 <td class="parameter_annotations"> </td>
454 </tr>
455 </tbody>
456 </table></div>
457 </div>
458 </div>
459 <hr>
460 <div class="refsect2">
461 <a name="g-async-queue-push-sorted"></a><h3>g_async_queue_push_sorted ()</h3>
462 <pre class="programlisting"><span class="returnvalue">void</span>
463 g_async_queue_push_sorted (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
464                            <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
465                            <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> func</code></em>,
466                            <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
467 <p>Inserts <em class="parameter"><code>data</code></em>
468  into <em class="parameter"><code>queue</code></em>
469  using <em class="parameter"><code>func</code></em>
470  to determine the new
471 position.</p>
472 <p>This function requires that the <em class="parameter"><code>queue</code></em>
473  is sorted before pushing on
474 new elements, see <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort" title="g_async_queue_sort ()"><code class="function">g_async_queue_sort()</code></a>.</p>
475 <p>This function will lock <em class="parameter"><code>queue</code></em>
476  before it sorts the queue and unlock
477 it when it is finished.</p>
478 <p>For an example of <em class="parameter"><code>func</code></em>
479  see <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort" title="g_async_queue_sort ()"><code class="function">g_async_queue_sort()</code></a>.</p>
480 <div class="refsect3">
481 <a name="g-async-queue-push-sorted.parameters"></a><h4>Parameters</h4>
482 <div class="informaltable"><table class="informaltable" width="100%" border="0">
483 <colgroup>
484 <col width="150px" class="parameters_name">
485 <col class="parameters_description">
486 <col width="200px" class="parameters_annotations">
487 </colgroup>
488 <tbody>
489 <tr>
490 <td class="parameter_name"><p>queue</p></td>
491 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
492 <td class="parameter_annotations"> </td>
493 </tr>
494 <tr>
495 <td class="parameter_name"><p>data</p></td>
496 <td class="parameter_description"><p>the <em class="parameter"><code>data</code></em>
497 to push into the <em class="parameter"><code>queue</code></em>
498 </p></td>
499 <td class="parameter_annotations"> </td>
500 </tr>
501 <tr>
502 <td class="parameter_name"><p>func</p></td>
503 <td class="parameter_description"><p>the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>
504 </p></td>
505 <td class="parameter_annotations"> </td>
506 </tr>
507 <tr>
508 <td class="parameter_name"><p>user_data</p></td>
509 <td class="parameter_description"><p>user data passed to <em class="parameter"><code>func</code></em>
510 .</p></td>
511 <td class="parameter_annotations"> </td>
512 </tr>
513 </tbody>
514 </table></div>
515 </div>
516 <p class="since">Since: <a class="link" href="api-index-2-10.html#api-index-2.10">2.10</a></p>
517 </div>
518 <hr>
519 <div class="refsect2">
520 <a name="g-async-queue-push-front"></a><h3>g_async_queue_push_front ()</h3>
521 <pre class="programlisting"><span class="returnvalue">void</span>
522 g_async_queue_push_front (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
523                           <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> item</code></em>);</pre>
524 <p>Pushes the <em class="parameter"><code>item</code></em>
525  into the <em class="parameter"><code>queue</code></em>
526 . <em class="parameter"><code>item</code></em>
527  must not be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
528 In contrast to <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push" title="g_async_queue_push ()"><code class="function">g_async_queue_push()</code></a>, this function
529 pushes the new item ahead of the items already in the queue,
530 so that it will be the next one to be popped off the queue.</p>
531 <div class="refsect3">
532 <a name="g-async-queue-push-front.parameters"></a><h4>Parameters</h4>
533 <div class="informaltable"><table class="informaltable" width="100%" border="0">
534 <colgroup>
535 <col width="150px" class="parameters_name">
536 <col class="parameters_description">
537 <col width="200px" class="parameters_annotations">
538 </colgroup>
539 <tbody>
540 <tr>
541 <td class="parameter_name"><p>queue</p></td>
542 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
543 <td class="parameter_annotations"> </td>
544 </tr>
545 <tr>
546 <td class="parameter_name"><p>item</p></td>
547 <td class="parameter_description"><p>data to push into the <em class="parameter"><code>queue</code></em>
548 </p></td>
549 <td class="parameter_annotations"> </td>
550 </tr>
551 </tbody>
552 </table></div>
553 </div>
554 <p class="since">Since: <a class="link" href="api-index-2-46.html#api-index-2.46">2.46</a></p>
555 </div>
556 <hr>
557 <div class="refsect2">
558 <a name="g-async-queue-remove"></a><h3>g_async_queue_remove ()</h3>
559 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
560 g_async_queue_remove (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
561                       <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> item</code></em>);</pre>
562 <p>Remove an item from the queue.</p>
563 <div class="refsect3">
564 <a name="g-async-queue-remove.parameters"></a><h4>Parameters</h4>
565 <div class="informaltable"><table class="informaltable" width="100%" border="0">
566 <colgroup>
567 <col width="150px" class="parameters_name">
568 <col class="parameters_description">
569 <col width="200px" class="parameters_annotations">
570 </colgroup>
571 <tbody>
572 <tr>
573 <td class="parameter_name"><p>queue</p></td>
574 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
575 <td class="parameter_annotations"> </td>
576 </tr>
577 <tr>
578 <td class="parameter_name"><p>item</p></td>
579 <td class="parameter_description"><p>the data to remove from the <em class="parameter"><code>queue</code></em>
580 </p></td>
581 <td class="parameter_annotations"> </td>
582 </tr>
583 </tbody>
584 </table></div>
585 </div>
586 <div class="refsect3">
587 <a name="g-async-queue-remove.returns"></a><h4>Returns</h4>
588 <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the item was removed</p>
589 </div>
590 <p class="since">Since: <a class="link" href="api-index-2-46.html#api-index-2.46">2.46</a></p>
591 </div>
592 <hr>
593 <div class="refsect2">
594 <a name="g-async-queue-pop"></a><h3>g_async_queue_pop ()</h3>
595 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
596 g_async_queue_pop (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
597 <p>Pops data from the <em class="parameter"><code>queue</code></em>
598 . If <em class="parameter"><code>queue</code></em>
599  is empty, this function
600 blocks until data becomes available.</p>
601 <div class="refsect3">
602 <a name="g-async-queue-pop.parameters"></a><h4>Parameters</h4>
603 <div class="informaltable"><table class="informaltable" width="100%" border="0">
604 <colgroup>
605 <col width="150px" class="parameters_name">
606 <col class="parameters_description">
607 <col width="200px" class="parameters_annotations">
608 </colgroup>
609 <tbody><tr>
610 <td class="parameter_name"><p>queue</p></td>
611 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
612 <td class="parameter_annotations"> </td>
613 </tr></tbody>
614 </table></div>
615 </div>
616 <div class="refsect3">
617 <a name="g-async-queue-pop.returns"></a><h4>Returns</h4>
618 <p> data from the queue</p>
619 </div>
620 </div>
621 <hr>
622 <div class="refsect2">
623 <a name="g-async-queue-try-pop"></a><h3>g_async_queue_try_pop ()</h3>
624 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
625 g_async_queue_try_pop (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
626 <p>Tries to pop data from the <em class="parameter"><code>queue</code></em>
627 . If no data is available,
628 <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.</p>
629 <div class="refsect3">
630 <a name="g-async-queue-try-pop.parameters"></a><h4>Parameters</h4>
631 <div class="informaltable"><table class="informaltable" width="100%" border="0">
632 <colgroup>
633 <col width="150px" class="parameters_name">
634 <col class="parameters_description">
635 <col width="200px" class="parameters_annotations">
636 </colgroup>
637 <tbody><tr>
638 <td class="parameter_name"><p>queue</p></td>
639 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
640 <td class="parameter_annotations"> </td>
641 </tr></tbody>
642 </table></div>
643 </div>
644 <div class="refsect3">
645 <a name="g-async-queue-try-pop.returns"></a><h4>Returns</h4>
646 <p> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, when no data is
647 available immediately.</p>
648 </div>
649 </div>
650 <hr>
651 <div class="refsect2">
652 <a name="g-async-queue-timeout-pop"></a><h3>g_async_queue_timeout_pop ()</h3>
653 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
654 g_async_queue_timeout_pop (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
655                            <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> timeout</code></em>);</pre>
656 <p>Pops data from the <em class="parameter"><code>queue</code></em>
657 . If the queue is empty, blocks for
658 <em class="parameter"><code>timeout</code></em>
659  microseconds, or until data becomes available.</p>
660 <p>If no data is received before the timeout, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.</p>
661 <div class="refsect3">
662 <a name="g-async-queue-timeout-pop.parameters"></a><h4>Parameters</h4>
663 <div class="informaltable"><table class="informaltable" width="100%" border="0">
664 <colgroup>
665 <col width="150px" class="parameters_name">
666 <col class="parameters_description">
667 <col width="200px" class="parameters_annotations">
668 </colgroup>
669 <tbody>
670 <tr>
671 <td class="parameter_name"><p>queue</p></td>
672 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
673 <td class="parameter_annotations"> </td>
674 </tr>
675 <tr>
676 <td class="parameter_name"><p>timeout</p></td>
677 <td class="parameter_description"><p>the number of microseconds to wait</p></td>
678 <td class="parameter_annotations"> </td>
679 </tr>
680 </tbody>
681 </table></div>
682 </div>
683 <div class="refsect3">
684 <a name="g-async-queue-timeout-pop.returns"></a><h4>Returns</h4>
685 <p> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, when no data is
686 received before the timeout.</p>
687 </div>
688 </div>
689 <hr>
690 <div class="refsect2">
691 <a name="g-async-queue-length"></a><h3>g_async_queue_length ()</h3>
692 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
693 g_async_queue_length (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
694 <p>Returns the length of the queue.</p>
695 <p>Actually this function returns the number of data items in
696 the queue minus the number of waiting threads, so a negative
697 value means waiting threads, and a positive value means available
698 entries in the <em class="parameter"><code>queue</code></em>
699 . A return value of 0 could mean n entries
700 in the queue and n threads waiting. This can happen due to locking
701 of the queue or due to scheduling.</p>
702 <div class="refsect3">
703 <a name="g-async-queue-length.parameters"></a><h4>Parameters</h4>
704 <div class="informaltable"><table class="informaltable" width="100%" border="0">
705 <colgroup>
706 <col width="150px" class="parameters_name">
707 <col class="parameters_description">
708 <col width="200px" class="parameters_annotations">
709 </colgroup>
710 <tbody><tr>
711 <td class="parameter_name"><p>queue</p></td>
712 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</p></td>
713 <td class="parameter_annotations"> </td>
714 </tr></tbody>
715 </table></div>
716 </div>
717 <div class="refsect3">
718 <a name="g-async-queue-length.returns"></a><h4>Returns</h4>
719 <p> the length of the <em class="parameter"><code>queue</code></em>
720 </p>
721 </div>
722 </div>
723 <hr>
724 <div class="refsect2">
725 <a name="g-async-queue-sort"></a><h3>g_async_queue_sort ()</h3>
726 <pre class="programlisting"><span class="returnvalue">void</span>
727 g_async_queue_sort (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
728                     <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> func</code></em>,
729                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
730 <p>Sorts <em class="parameter"><code>queue</code></em>
731  using <em class="parameter"><code>func</code></em>
732 .</p>
733 <p>The sort function <em class="parameter"><code>func</code></em>
734  is passed two elements of the <em class="parameter"><code>queue</code></em>
735 .
736 It should return 0 if they are equal, a negative value if the
737 first element should be higher in the <em class="parameter"><code>queue</code></em>
738  or a positive value
739 if the first element should be lower in the <em class="parameter"><code>queue</code></em>
740  than the second
741 element.</p>
742 <p>This function will lock <em class="parameter"><code>queue</code></em>
743  before it sorts the queue and unlock
744 it when it is finished.</p>
745 <p>If you were sorting a list of priority numbers to make sure the
746 lowest priority would be at the top of the queue, you could use:</p>
747 <div class="informalexample">
748   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
749     <tbody>
750       <tr>
751         <td class="listing_lines" align="right"><pre>1
752 2
753 3
754 4
755 5
756 6
757 7</pre></td>
758         <td class="listing_code"><pre class="programlisting">gint32 id1<span class="gtkdoc opt">;</span>
759 gint32 id2<span class="gtkdoc opt">;</span>
760
761 id1 <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Type-Conversion-Macros.html#GPOINTER-TO-INT:CAPS">GPOINTER_TO_INT</a></span> <span class="gtkdoc opt">(</span>element1<span class="gtkdoc opt">);</span>
762 id2 <span class="gtkdoc opt">=</span> <span class="function"><a href="glib-Type-Conversion-Macros.html#GPOINTER-TO-INT:CAPS">GPOINTER_TO_INT</a></span> <span class="gtkdoc opt">(</span>element2<span class="gtkdoc opt">);</span>
763
764 <span class="keyword">return</span> <span class="gtkdoc opt">(</span>id1 <span class="gtkdoc opt">&gt;</span> id2 ? <span class="gtkdoc opt">+</span><span class="number">1</span> <span class="gtkdoc opt">:</span> id1 <span class="gtkdoc opt">==</span> id2 ? <span class="number">0</span> <span class="gtkdoc opt">: -</span><span class="number">1</span><span class="gtkdoc opt">);</span></pre></td>
765       </tr>
766     </tbody>
767   </table>
768 </div>
769
770 <p></p>
771 <div class="refsect3">
772 <a name="g-async-queue-sort.parameters"></a><h4>Parameters</h4>
773 <div class="informaltable"><table class="informaltable" width="100%" border="0">
774 <colgroup>
775 <col width="150px" class="parameters_name">
776 <col class="parameters_description">
777 <col width="200px" class="parameters_annotations">
778 </colgroup>
779 <tbody>
780 <tr>
781 <td class="parameter_name"><p>queue</p></td>
782 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
783 <td class="parameter_annotations"> </td>
784 </tr>
785 <tr>
786 <td class="parameter_name"><p>func</p></td>
787 <td class="parameter_description"><p>the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>
788 </p></td>
789 <td class="parameter_annotations"> </td>
790 </tr>
791 <tr>
792 <td class="parameter_name"><p>user_data</p></td>
793 <td class="parameter_description"><p>user data passed to <em class="parameter"><code>func</code></em>
794 </p></td>
795 <td class="parameter_annotations"> </td>
796 </tr>
797 </tbody>
798 </table></div>
799 </div>
800 <p class="since">Since: <a class="link" href="api-index-2-10.html#api-index-2.10">2.10</a></p>
801 </div>
802 <hr>
803 <div class="refsect2">
804 <a name="g-async-queue-lock"></a><h3>g_async_queue_lock ()</h3>
805 <pre class="programlisting"><span class="returnvalue">void</span>
806 g_async_queue_lock (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
807 <p>Acquires the <em class="parameter"><code>queue</code></em>
808 's lock. If another thread is already
809 holding the lock, this call will block until the lock
810 becomes available.</p>
811 <p>Call <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unlock" title="g_async_queue_unlock ()"><code class="function">g_async_queue_unlock()</code></a> to drop the lock again.</p>
812 <p>While holding the lock, you can only call the
813 g_async_queue_*_unlocked() functions on <em class="parameter"><code>queue</code></em>
814 . Otherwise,
815 deadlock may occur.</p>
816 <div class="refsect3">
817 <a name="g-async-queue-lock.parameters"></a><h4>Parameters</h4>
818 <div class="informaltable"><table class="informaltable" width="100%" border="0">
819 <colgroup>
820 <col width="150px" class="parameters_name">
821 <col class="parameters_description">
822 <col width="200px" class="parameters_annotations">
823 </colgroup>
824 <tbody><tr>
825 <td class="parameter_name"><p>queue</p></td>
826 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
827 <td class="parameter_annotations"> </td>
828 </tr></tbody>
829 </table></div>
830 </div>
831 </div>
832 <hr>
833 <div class="refsect2">
834 <a name="g-async-queue-unlock"></a><h3>g_async_queue_unlock ()</h3>
835 <pre class="programlisting"><span class="returnvalue">void</span>
836 g_async_queue_unlock (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
837 <p>Releases the queue's lock.</p>
838 <p>Calling this function when you have not acquired
839 the with <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-lock" title="g_async_queue_lock ()"><code class="function">g_async_queue_lock()</code></a> leads to undefined
840 behaviour.</p>
841 <div class="refsect3">
842 <a name="g-async-queue-unlock.parameters"></a><h4>Parameters</h4>
843 <div class="informaltable"><table class="informaltable" width="100%" border="0">
844 <colgroup>
845 <col width="150px" class="parameters_name">
846 <col class="parameters_description">
847 <col width="200px" class="parameters_annotations">
848 </colgroup>
849 <tbody><tr>
850 <td class="parameter_name"><p>queue</p></td>
851 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
852 <td class="parameter_annotations"> </td>
853 </tr></tbody>
854 </table></div>
855 </div>
856 </div>
857 <hr>
858 <div class="refsect2">
859 <a name="g-async-queue-ref-unlocked"></a><h3>g_async_queue_ref_unlocked ()</h3>
860 <pre class="programlisting"><span class="returnvalue">void</span>
861 g_async_queue_ref_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
862 <div class="warning">
863 <p><code class="literal">g_async_queue_ref_unlocked</code> has been deprecated since version 2.8 and should not be used in newly-written code.</p>
864 <p>Reference counting is done atomically.
865 so <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-ref" title="g_async_queue_ref ()"><code class="function">g_async_queue_ref()</code></a> can be used regardless of the <em class="parameter"><code>queue</code></em>
866 's
867 lock.</p>
868 </div>
869 <p>Increases the reference count of the asynchronous <em class="parameter"><code>queue</code></em>
870  by 1.</p>
871 <div class="refsect3">
872 <a name="g-async-queue-ref-unlocked.parameters"></a><h4>Parameters</h4>
873 <div class="informaltable"><table class="informaltable" width="100%" border="0">
874 <colgroup>
875 <col width="150px" class="parameters_name">
876 <col class="parameters_description">
877 <col width="200px" class="parameters_annotations">
878 </colgroup>
879 <tbody><tr>
880 <td class="parameter_name"><p>queue</p></td>
881 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
882 <td class="parameter_annotations"> </td>
883 </tr></tbody>
884 </table></div>
885 </div>
886 </div>
887 <hr>
888 <div class="refsect2">
889 <a name="g-async-queue-unref-and-unlock"></a><h3>g_async_queue_unref_and_unlock ()</h3>
890 <pre class="programlisting"><span class="returnvalue">void</span>
891 g_async_queue_unref_and_unlock (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
892 <div class="warning">
893 <p><code class="literal">g_async_queue_unref_and_unlock</code> has been deprecated since version 2.8 and should not be used in newly-written code.</p>
894 <p>Reference counting is done atomically.
895 so <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-unref" title="g_async_queue_unref ()"><code class="function">g_async_queue_unref()</code></a> can be used regardless of the <em class="parameter"><code>queue</code></em>
896 's
897 lock.</p>
898 </div>
899 <p>Decreases the reference count of the asynchronous <em class="parameter"><code>queue</code></em>
900  by 1
901 and releases the lock. This function must be called while holding
902 the <em class="parameter"><code>queue</code></em>
903 's lock. If the reference count went to 0, the <em class="parameter"><code>queue</code></em>
904
905 will be destroyed and the memory allocated will be freed.</p>
906 <div class="refsect3">
907 <a name="g-async-queue-unref-and-unlock.parameters"></a><h4>Parameters</h4>
908 <div class="informaltable"><table class="informaltable" width="100%" border="0">
909 <colgroup>
910 <col width="150px" class="parameters_name">
911 <col class="parameters_description">
912 <col width="200px" class="parameters_annotations">
913 </colgroup>
914 <tbody><tr>
915 <td class="parameter_name"><p>queue</p></td>
916 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
917 <td class="parameter_annotations"> </td>
918 </tr></tbody>
919 </table></div>
920 </div>
921 </div>
922 <hr>
923 <div class="refsect2">
924 <a name="g-async-queue-push-unlocked"></a><h3>g_async_queue_push_unlocked ()</h3>
925 <pre class="programlisting"><span class="returnvalue">void</span>
926 g_async_queue_push_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
927                              <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
928 <p>Pushes the <em class="parameter"><code>data</code></em>
929  into the <em class="parameter"><code>queue</code></em>
930 . <em class="parameter"><code>data</code></em>
931  must not be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.</p>
932 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
933 's lock.</p>
934 <div class="refsect3">
935 <a name="g-async-queue-push-unlocked.parameters"></a><h4>Parameters</h4>
936 <div class="informaltable"><table class="informaltable" width="100%" border="0">
937 <colgroup>
938 <col width="150px" class="parameters_name">
939 <col class="parameters_description">
940 <col width="200px" class="parameters_annotations">
941 </colgroup>
942 <tbody>
943 <tr>
944 <td class="parameter_name"><p>queue</p></td>
945 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
946 <td class="parameter_annotations"> </td>
947 </tr>
948 <tr>
949 <td class="parameter_name"><p>data</p></td>
950 <td class="parameter_description"><p><em class="parameter"><code>data</code></em>
951 to push into the <em class="parameter"><code>queue</code></em>
952 </p></td>
953 <td class="parameter_annotations"> </td>
954 </tr>
955 </tbody>
956 </table></div>
957 </div>
958 </div>
959 <hr>
960 <div class="refsect2">
961 <a name="g-async-queue-push-sorted-unlocked"></a><h3>g_async_queue_push_sorted_unlocked ()</h3>
962 <pre class="programlisting"><span class="returnvalue">void</span>
963 g_async_queue_push_sorted_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
964                                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> data</code></em>,
965                                     <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> func</code></em>,
966                                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
967 <p>Inserts <em class="parameter"><code>data</code></em>
968  into <em class="parameter"><code>queue</code></em>
969  using <em class="parameter"><code>func</code></em>
970  to determine the new
971 position.</p>
972 <p>The sort function <em class="parameter"><code>func</code></em>
973  is passed two elements of the <em class="parameter"><code>queue</code></em>
974 .
975 It should return 0 if they are equal, a negative value if the
976 first element should be higher in the <em class="parameter"><code>queue</code></em>
977  or a positive value
978 if the first element should be lower in the <em class="parameter"><code>queue</code></em>
979  than the second
980 element.</p>
981 <p>This function requires that the <em class="parameter"><code>queue</code></em>
982  is sorted before pushing on
983 new elements, see <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort" title="g_async_queue_sort ()"><code class="function">g_async_queue_sort()</code></a>.</p>
984 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
985 's lock.</p>
986 <p>For an example of <em class="parameter"><code>func</code></em>
987  see <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort" title="g_async_queue_sort ()"><code class="function">g_async_queue_sort()</code></a>.</p>
988 <div class="refsect3">
989 <a name="g-async-queue-push-sorted-unlocked.parameters"></a><h4>Parameters</h4>
990 <div class="informaltable"><table class="informaltable" width="100%" border="0">
991 <colgroup>
992 <col width="150px" class="parameters_name">
993 <col class="parameters_description">
994 <col width="200px" class="parameters_annotations">
995 </colgroup>
996 <tbody>
997 <tr>
998 <td class="parameter_name"><p>queue</p></td>
999 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1000 <td class="parameter_annotations"> </td>
1001 </tr>
1002 <tr>
1003 <td class="parameter_name"><p>data</p></td>
1004 <td class="parameter_description"><p>the <em class="parameter"><code>data</code></em>
1005 to push into the <em class="parameter"><code>queue</code></em>
1006 </p></td>
1007 <td class="parameter_annotations"> </td>
1008 </tr>
1009 <tr>
1010 <td class="parameter_name"><p>func</p></td>
1011 <td class="parameter_description"><p>the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>
1012 </p></td>
1013 <td class="parameter_annotations"> </td>
1014 </tr>
1015 <tr>
1016 <td class="parameter_name"><p>user_data</p></td>
1017 <td class="parameter_description"><p>user data passed to <em class="parameter"><code>func</code></em>
1018 .</p></td>
1019 <td class="parameter_annotations"> </td>
1020 </tr>
1021 </tbody>
1022 </table></div>
1023 </div>
1024 <p class="since">Since: <a class="link" href="api-index-2-10.html#api-index-2.10">2.10</a></p>
1025 </div>
1026 <hr>
1027 <div class="refsect2">
1028 <a name="g-async-queue-push-front-unlocked"></a><h3>g_async_queue_push_front_unlocked ()</h3>
1029 <pre class="programlisting"><span class="returnvalue">void</span>
1030 g_async_queue_push_front_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
1031                                    <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> item</code></em>);</pre>
1032 <p>Pushes the <em class="parameter"><code>item</code></em>
1033  into the <em class="parameter"><code>queue</code></em>
1034 . <em class="parameter"><code>item</code></em>
1035  must not be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>.
1036 In contrast to <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-push-unlocked" title="g_async_queue_push_unlocked ()"><code class="function">g_async_queue_push_unlocked()</code></a>, this function
1037 pushes the new item ahead of the items already in the queue,
1038 so that it will be the next one to be popped off the queue.</p>
1039 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1040 's lock.</p>
1041 <div class="refsect3">
1042 <a name="g-async-queue-push-front-unlocked.parameters"></a><h4>Parameters</h4>
1043 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1044 <colgroup>
1045 <col width="150px" class="parameters_name">
1046 <col class="parameters_description">
1047 <col width="200px" class="parameters_annotations">
1048 </colgroup>
1049 <tbody>
1050 <tr>
1051 <td class="parameter_name"><p>queue</p></td>
1052 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1053 <td class="parameter_annotations"> </td>
1054 </tr>
1055 <tr>
1056 <td class="parameter_name"><p>item</p></td>
1057 <td class="parameter_description"><p>data to push into the <em class="parameter"><code>queue</code></em>
1058 </p></td>
1059 <td class="parameter_annotations"> </td>
1060 </tr>
1061 </tbody>
1062 </table></div>
1063 </div>
1064 <p class="since">Since: <a class="link" href="api-index-2-46.html#api-index-2.46">2.46</a></p>
1065 </div>
1066 <hr>
1067 <div class="refsect2">
1068 <a name="g-async-queue-remove-unlocked"></a><h3>g_async_queue_remove_unlocked ()</h3>
1069 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>
1070 g_async_queue_remove_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
1071                                <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> item</code></em>);</pre>
1072 <p>Remove an item from the queue.</p>
1073 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1074 's lock.</p>
1075 <div class="refsect3">
1076 <a name="g-async-queue-remove-unlocked.parameters"></a><h4>Parameters</h4>
1077 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1078 <colgroup>
1079 <col width="150px" class="parameters_name">
1080 <col class="parameters_description">
1081 <col width="200px" class="parameters_annotations">
1082 </colgroup>
1083 <tbody>
1084 <tr>
1085 <td class="parameter_name"><p>queue</p></td>
1086 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1087 <td class="parameter_annotations"> </td>
1088 </tr>
1089 <tr>
1090 <td class="parameter_name"><p>item</p></td>
1091 <td class="parameter_description"><p>the data to remove from the <em class="parameter"><code>queue</code></em>
1092 </p></td>
1093 <td class="parameter_annotations"> </td>
1094 </tr>
1095 </tbody>
1096 </table></div>
1097 </div>
1098 <div class="refsect3">
1099 <a name="g-async-queue-remove-unlocked.returns"></a><h4>Returns</h4>
1100 <p> <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the item was removed</p>
1101 </div>
1102 <p class="since">Since: <a class="link" href="api-index-2-46.html#api-index-2.46">2.46</a></p>
1103 </div>
1104 <hr>
1105 <div class="refsect2">
1106 <a name="g-async-queue-pop-unlocked"></a><h3>g_async_queue_pop_unlocked ()</h3>
1107 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
1108 g_async_queue_pop_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
1109 <p>Pops data from the <em class="parameter"><code>queue</code></em>
1110 . If <em class="parameter"><code>queue</code></em>
1111  is empty, this function
1112 blocks until data becomes available.</p>
1113 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1114 's lock.</p>
1115 <div class="refsect3">
1116 <a name="g-async-queue-pop-unlocked.parameters"></a><h4>Parameters</h4>
1117 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1118 <colgroup>
1119 <col width="150px" class="parameters_name">
1120 <col class="parameters_description">
1121 <col width="200px" class="parameters_annotations">
1122 </colgroup>
1123 <tbody><tr>
1124 <td class="parameter_name"><p>queue</p></td>
1125 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1126 <td class="parameter_annotations"> </td>
1127 </tr></tbody>
1128 </table></div>
1129 </div>
1130 <div class="refsect3">
1131 <a name="g-async-queue-pop-unlocked.returns"></a><h4>Returns</h4>
1132 <p> data from the queue.</p>
1133 </div>
1134 </div>
1135 <hr>
1136 <div class="refsect2">
1137 <a name="g-async-queue-try-pop-unlocked"></a><h3>g_async_queue_try_pop_unlocked ()</h3>
1138 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
1139 g_async_queue_try_pop_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
1140 <p>Tries to pop data from the <em class="parameter"><code>queue</code></em>
1141 . If no data is available,
1142 <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.</p>
1143 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1144 's lock.</p>
1145 <div class="refsect3">
1146 <a name="g-async-queue-try-pop-unlocked.parameters"></a><h4>Parameters</h4>
1147 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1148 <colgroup>
1149 <col width="150px" class="parameters_name">
1150 <col class="parameters_description">
1151 <col width="200px" class="parameters_annotations">
1152 </colgroup>
1153 <tbody><tr>
1154 <td class="parameter_name"><p>queue</p></td>
1155 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1156 <td class="parameter_annotations"> </td>
1157 </tr></tbody>
1158 </table></div>
1159 </div>
1160 <div class="refsect3">
1161 <a name="g-async-queue-try-pop-unlocked.returns"></a><h4>Returns</h4>
1162 <p> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, when no data is
1163 available immediately.</p>
1164 </div>
1165 </div>
1166 <hr>
1167 <div class="refsect2">
1168 <a name="g-async-queue-timeout-pop-unlocked"></a><h3>g_async_queue_timeout_pop_unlocked ()</h3>
1169 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
1170 g_async_queue_timeout_pop_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
1171                                     <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a> timeout</code></em>);</pre>
1172 <p>Pops data from the <em class="parameter"><code>queue</code></em>
1173 . If the queue is empty, blocks for
1174 <em class="parameter"><code>timeout</code></em>
1175  microseconds, or until data becomes available.</p>
1176 <p>If no data is received before the timeout, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.</p>
1177 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1178 's lock.</p>
1179 <div class="refsect3">
1180 <a name="g-async-queue-timeout-pop-unlocked.parameters"></a><h4>Parameters</h4>
1181 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1182 <colgroup>
1183 <col width="150px" class="parameters_name">
1184 <col class="parameters_description">
1185 <col width="200px" class="parameters_annotations">
1186 </colgroup>
1187 <tbody>
1188 <tr>
1189 <td class="parameter_name"><p>queue</p></td>
1190 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1191 <td class="parameter_annotations"> </td>
1192 </tr>
1193 <tr>
1194 <td class="parameter_name"><p>timeout</p></td>
1195 <td class="parameter_description"><p>the number of microseconds to wait</p></td>
1196 <td class="parameter_annotations"> </td>
1197 </tr>
1198 </tbody>
1199 </table></div>
1200 </div>
1201 <div class="refsect3">
1202 <a name="g-async-queue-timeout-pop-unlocked.returns"></a><h4>Returns</h4>
1203 <p> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, when no data is
1204 received before the timeout.</p>
1205 </div>
1206 </div>
1207 <hr>
1208 <div class="refsect2">
1209 <a name="g-async-queue-length-unlocked"></a><h3>g_async_queue_length_unlocked ()</h3>
1210 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint ()"><span class="returnvalue">gint</span></a>
1211 g_async_queue_length_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>);</pre>
1212 <p>Returns the length of the queue.</p>
1213 <p>Actually this function returns the number of data items in
1214 the queue minus the number of waiting threads, so a negative
1215 value means waiting threads, and a positive value means available
1216 entries in the <em class="parameter"><code>queue</code></em>
1217 . A return value of 0 could mean n entries
1218 in the queue and n threads waiting. This can happen due to locking
1219 of the queue or due to scheduling.</p>
1220 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1221 's lock.</p>
1222 <div class="refsect3">
1223 <a name="g-async-queue-length-unlocked.parameters"></a><h4>Parameters</h4>
1224 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1225 <colgroup>
1226 <col width="150px" class="parameters_name">
1227 <col class="parameters_description">
1228 <col width="200px" class="parameters_annotations">
1229 </colgroup>
1230 <tbody><tr>
1231 <td class="parameter_name"><p>queue</p></td>
1232 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1233 <td class="parameter_annotations"> </td>
1234 </tr></tbody>
1235 </table></div>
1236 </div>
1237 <div class="refsect3">
1238 <a name="g-async-queue-length-unlocked.returns"></a><h4>Returns</h4>
1239 <p> the length of the <em class="parameter"><code>queue</code></em>
1240 .</p>
1241 </div>
1242 </div>
1243 <hr>
1244 <div class="refsect2">
1245 <a name="g-async-queue-sort-unlocked"></a><h3>g_async_queue_sort_unlocked ()</h3>
1246 <pre class="programlisting"><span class="returnvalue">void</span>
1247 g_async_queue_sort_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
1248                              <em class="parameter"><code><a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> func</code></em>,
1249                              <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
1250 <p>Sorts <em class="parameter"><code>queue</code></em>
1251  using <em class="parameter"><code>func</code></em>
1252 .</p>
1253 <p>The sort function <em class="parameter"><code>func</code></em>
1254  is passed two elements of the <em class="parameter"><code>queue</code></em>
1255 .
1256 It should return 0 if they are equal, a negative value if the
1257 first element should be higher in the <em class="parameter"><code>queue</code></em>
1258  or a positive value
1259 if the first element should be lower in the <em class="parameter"><code>queue</code></em>
1260  than the second
1261 element.</p>
1262 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1263 's lock.</p>
1264 <div class="refsect3">
1265 <a name="g-async-queue-sort-unlocked.parameters"></a><h4>Parameters</h4>
1266 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1267 <colgroup>
1268 <col width="150px" class="parameters_name">
1269 <col class="parameters_description">
1270 <col width="200px" class="parameters_annotations">
1271 </colgroup>
1272 <tbody>
1273 <tr>
1274 <td class="parameter_name"><p>queue</p></td>
1275 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1276 <td class="parameter_annotations"> </td>
1277 </tr>
1278 <tr>
1279 <td class="parameter_name"><p>func</p></td>
1280 <td class="parameter_description"><p>the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc" title="GCompareDataFunc ()"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>
1281 </p></td>
1282 <td class="parameter_annotations"> </td>
1283 </tr>
1284 <tr>
1285 <td class="parameter_name"><p>user_data</p></td>
1286 <td class="parameter_description"><p>user data passed to <em class="parameter"><code>func</code></em>
1287 </p></td>
1288 <td class="parameter_annotations"> </td>
1289 </tr>
1290 </tbody>
1291 </table></div>
1292 </div>
1293 <p class="since">Since: <a class="link" href="api-index-2-10.html#api-index-2.10">2.10</a></p>
1294 </div>
1295 <hr>
1296 <div class="refsect2">
1297 <a name="g-async-queue-timed-pop"></a><h3>g_async_queue_timed_pop ()</h3>
1298 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
1299 g_async_queue_timed_pop (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
1300                          <em class="parameter"><code><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a> *end_time</code></em>);</pre>
1301 <div class="warning">
1302 <p><code class="literal">g_async_queue_timed_pop</code> is deprecated and should not be used in newly-written code.</p>
1303 <p>use <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timeout-pop" title="g_async_queue_timeout_pop ()"><code class="function">g_async_queue_timeout_pop()</code></a>.</p>
1304 </div>
1305 <p>Pops data from the <em class="parameter"><code>queue</code></em>
1306 . If the queue is empty, blocks until
1307 <em class="parameter"><code>end_time</code></em>
1308  or until data becomes available.</p>
1309 <p>If no data is received before <em class="parameter"><code>end_time</code></em>
1310 , <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.</p>
1311 <p>To easily calculate <em class="parameter"><code>end_time</code></em>
1312 , a combination of <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time" title="g_get_current_time ()"><code class="function">g_get_current_time()</code></a>
1313 and <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-add" title="g_time_val_add ()"><code class="function">g_time_val_add()</code></a> can be used.</p>
1314 <div class="refsect3">
1315 <a name="g-async-queue-timed-pop.parameters"></a><h4>Parameters</h4>
1316 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1317 <colgroup>
1318 <col width="150px" class="parameters_name">
1319 <col class="parameters_description">
1320 <col width="200px" class="parameters_annotations">
1321 </colgroup>
1322 <tbody>
1323 <tr>
1324 <td class="parameter_name"><p>queue</p></td>
1325 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1326 <td class="parameter_annotations"> </td>
1327 </tr>
1328 <tr>
1329 <td class="parameter_name"><p>end_time</p></td>
1330 <td class="parameter_description"><p>a <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a>, determining the final time</p></td>
1331 <td class="parameter_annotations"> </td>
1332 </tr>
1333 </tbody>
1334 </table></div>
1335 </div>
1336 <div class="refsect3">
1337 <a name="g-async-queue-timed-pop.returns"></a><h4>Returns</h4>
1338 <p> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, when no data is
1339 received before <em class="parameter"><code>end_time</code></em>
1340 .</p>
1341 </div>
1342 </div>
1343 <hr>
1344 <div class="refsect2">
1345 <a name="g-async-queue-timed-pop-unlocked"></a><h3>g_async_queue_timed_pop_unlocked ()</h3>
1346 <pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>
1347 g_async_queue_timed_pop_unlocked (<em class="parameter"><code><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a> *queue</code></em>,
1348                                   <em class="parameter"><code><a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a> *end_time</code></em>);</pre>
1349 <div class="warning">
1350 <p><code class="literal">g_async_queue_timed_pop_unlocked</code> is deprecated and should not be used in newly-written code.</p>
1351 <p>use <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timeout-pop-unlocked" title="g_async_queue_timeout_pop_unlocked ()"><code class="function">g_async_queue_timeout_pop_unlocked()</code></a>.</p>
1352 </div>
1353 <p>Pops data from the <em class="parameter"><code>queue</code></em>
1354 . If the queue is empty, blocks until
1355 <em class="parameter"><code>end_time</code></em>
1356  or until data becomes available.</p>
1357 <p>If no data is received before <em class="parameter"><code>end_time</code></em>
1358 , <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a> is returned.</p>
1359 <p>To easily calculate <em class="parameter"><code>end_time</code></em>
1360 , a combination of <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time" title="g_get_current_time ()"><code class="function">g_get_current_time()</code></a>
1361 and <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-add" title="g_time_val_add ()"><code class="function">g_time_val_add()</code></a> can be used.</p>
1362 <p>This function must be called while holding the <em class="parameter"><code>queue</code></em>
1363 's lock.</p>
1364 <div class="refsect3">
1365 <a name="g-async-queue-timed-pop-unlocked.parameters"></a><h4>Parameters</h4>
1366 <div class="informaltable"><table class="informaltable" width="100%" border="0">
1367 <colgroup>
1368 <col width="150px" class="parameters_name">
1369 <col class="parameters_description">
1370 <col width="200px" class="parameters_annotations">
1371 </colgroup>
1372 <tbody>
1373 <tr>
1374 <td class="parameter_name"><p>queue</p></td>
1375 <td class="parameter_description"><p>a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue" title="GAsyncQueue"><span class="type">GAsyncQueue</span></a></p></td>
1376 <td class="parameter_annotations"> </td>
1377 </tr>
1378 <tr>
1379 <td class="parameter_name"><p>end_time</p></td>
1380 <td class="parameter_description"><p>a <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal" title="struct GTimeVal"><span class="type">GTimeVal</span></a>, determining the final time</p></td>
1381 <td class="parameter_annotations"> </td>
1382 </tr>
1383 </tbody>
1384 </table></div>
1385 </div>
1386 <div class="refsect3">
1387 <a name="g-async-queue-timed-pop-unlocked.returns"></a><h4>Returns</h4>
1388 <p> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>, when no data is
1389 received before <em class="parameter"><code>end_time</code></em>
1390 .</p>
1391 </div>
1392 </div>
1393 </div>
1394 <div class="refsect1">
1395 <a name="glib-Asynchronous-Queues.other_details"></a><h2>Types and Values</h2>
1396 <div class="refsect2">
1397 <a name="GAsyncQueue"></a><h3>GAsyncQueue</h3>
1398 <pre class="programlisting">typedef struct _GAsyncQueue GAsyncQueue;</pre>
1399 <p>The GAsyncQueue struct is an opaque data structure which represents
1400 an asynchronous queue. It should only be accessed through the
1401 g_async_queue_* functions.</p>
1402 </div>
1403 </div>
1404 <div class="refsect1">
1405 <a name="glib-Asynchronous-Queues.see-also"></a><h2>See Also</h2>
1406 <p><a class="link" href="glib-Thread-Pools.html#GThreadPool" title="struct GThreadPool"><span class="type">GThreadPool</span></a></p>
1407 </div>
1408 </div>
1409 <div class="footer">
1410 <hr>Generated by GTK-Doc V1.25.1</div>
1411 </body>
1412 </html>