📄 glib-asynchronous-queues.html
字号:
<a name="id2910688"></a><h3><a name="g-async-queue-ref"></a>g_async_queue_ref ()</h3><a class="indexterm" name="id2910701"></a><pre class="programlisting"><a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a>* g_async_queue_ref (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre><p>Increases the reference count of the asynchronous <em class="parameter"><code>queue</code></em> by 1. Youdo not need to hold the lock to call this function.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>queue</code></em> :</span></p></td><td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the <em class="parameter"><code>queue</code></em> that was passed in (since 2.6)</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2910780"></a><h3><a name="g-async-queue-unref"></a>g_async_queue_unref ()</h3><a class="indexterm" name="id2910794"></a><pre class="programlisting">void g_async_queue_unref (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre><p>Decreases the reference count of the asynchronous <em class="parameter"><code>queue</code></em> by 1. Ifthe reference count went to 0, the <em class="parameter"><code>queue</code></em> will be destroyed and thememory allocated will be freed. So you are not allowed to use the<em class="parameter"><code>queue</code></em> afterwards, as it might have disappeared. You do not need tohold the lock to call this function.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>queue</code></em> :</span></p></td><td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2910871"></a><h3><a name="g-async-queue-push"></a>g_async_queue_push ()</h3><a class="indexterm" name="id2910884"></a><pre class="programlisting">void g_async_queue_push (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data);</pre><p>Pushes the <em class="parameter"><code>data</code></em> into the <em class="parameter"><code>queue</code></em>. <em class="parameter"><code>data</code></em> must not be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>queue</code></em> :</span></p></td><td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td><td> <em class="parameter"><code>data</code></em> to push into the <em class="parameter"><code>queue</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2911000"></a><h3><a name="g-async-queue-push-sorted"></a>g_async_queue_push_sorted ()</h3><a class="indexterm" name="id2911017"></a><pre class="programlisting">void g_async_queue_push_sorted (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data, <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc">GCompareDataFunc</a> func, <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> user_data);</pre><p>Inserts <em class="parameter"><code>data</code></em> into <em class="parameter"><code>queue</code></em> using <em class="parameter"><code>func</code></em> to determine the newposition. </p><p>This function requires that the <em class="parameter"><code>queue</code></em> is sorted before pushing onnew elements.</p><p>This function will lock <em class="parameter"><code>queue</code></em> before it sorts the queue and unlockit when it is finished.</p><p>For an example of <em class="parameter"><code>func</code></em> see <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-sort"><code class="function">g_async_queue_sort()</code></a>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>queue</code></em> :</span></p></td><td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td><td> the <em class="parameter"><code>data</code></em> to push into the <em class="parameter"><code>queue</code></em></td></tr><tr><td><p><span class="term"><em class="parameter"><code>func</code></em> :</span></p></td><td> the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc"><span class="type">GCompareDataFunc</span></a> is used to sort <em class="parameter"><code>queue</code></em>. This function is passed two elements of the <em class="parameter"><code>queue</code></em>. The function should return 0 if they are equal, a negative value if the first element should be higher in the <em class="parameter"><code>queue</code></em> or a positive value if the first element should be lower in the <em class="parameter"><code>queue</code></em> than the second element.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td><td> user data passed to <em class="parameter"><code>func</code></em>.</td></tr></tbody></table></div><p class="since">Since 2.10</p></div><hr><div class="refsect2" lang="en"><a name="id2911260"></a><h3><a name="g-async-queue-pop"></a>g_async_queue_pop ()</h3><a class="indexterm" name="id2911273"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_pop (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre><p>Pops data from the <em class="parameter"><code>queue</code></em>. This function blocks until data becomeavailable.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>queue</code></em> :</span></p></td><td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> data from the queue.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2911346"></a><h3><a name="g-async-queue-try-pop"></a>g_async_queue_try_pop ()</h3><a class="indexterm" name="id2911359"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_try_pop (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre><p>Tries to pop data from the <em class="parameter"><code>queue</code></em>. If no data is available, <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> isreturned.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>queue</code></em> :</span></p></td><td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, when no data isavailable immediately.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2911453"></a><h3><a name="g-async-queue-timed-pop"></a>g_async_queue_timed_pop ()</h3><a class="indexterm" name="id2911465"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_timed_pop (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue, <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal">GTimeVal</a> *end_time);</pre><p>Pops data from the <em class="parameter"><code>queue</code></em>. If no data is received before <em class="parameter"><code>end_time</code></em>,<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> is returned.</p><p>To easily calculate <em class="parameter"><code>end_time</code></em> a combination of <a class="link" href="glib-Date-and-Time-Functions.html#g-get-current-time"><code class="function">g_get_current_time()</code></a>and <a class="link" href="glib-Date-and-Time-Functions.html#g-time-val-add"><code class="function">g_time_val_add()</code></a> can be used.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>queue</code></em> :</span></p></td><td> a <a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>end_time</code></em> :</span></p></td><td> a <a class="link" href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a>, determining the final time.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> data from the queue or <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, when no data isreceived before <em class="parameter"><code>end_time</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2911632"></a><h3><a name="g-async-queue-length"></a>g_async_queue_length ()</h3>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -