📄 glib-asynchronous-queues.html
字号:
<div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>queue</code></em> :</span></td><td> a <a 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="id2895689"></a><h3><a name="g-async-queue-unref-and-unlock"></a>g_async_queue_unref_and_unlock ()</h3><a class="indexterm" name="id2895700"></a><pre class="programlisting">void g_async_queue_unref_and_unlock (<a href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p><code class="literal">g_async_queue_unref_and_unlock</code> is deprecated and should not be used in newly-written code.</p></div><p>Decreases the reference count of the asynchronous <em class="parameter"><code>queue</code></em> by 1 andreleases the lock. This function must be called while holding the<em class="parameter"><code>queue</code></em>'s lock. If the reference count went to 0, the <em class="parameter"><code>queue</code></em> will bedestroyed and the memory allocated will be freed.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>queue</code></em> :</span></td><td> a <a 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="id2895790"></a><h3><a name="g-async-queue-push-unlocked"></a>g_async_queue_push_unlocked ()</h3><a class="indexterm" name="id2895802"></a><pre class="programlisting">void g_async_queue_push_unlocked (<a href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue, <a 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 <code class="literal">NULL</code>. Thisfunction must be called while holding the <em class="parameter"><code>queue</code></em>'s lock.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>queue</code></em> :</span></td><td> a <a href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>data</code></em> :</span></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="id2895920"></a><h3><a name="g-async-queue-pop-unlocked"></a>g_async_queue_pop_unlocked ()</h3><a class="indexterm" name="id2895932"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_pop_unlocked (<a 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. This function must be called while holding the <em class="parameter"><code>queue</code></em>'slock.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>queue</code></em> :</span></td><td> a <a href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> data from the queue.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2896010"></a><h3><a name="g-async-queue-try-pop-unlocked"></a>g_async_queue_try_pop_unlocked ()</h3><a class="indexterm" name="id2896021"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_try_pop_unlocked (<a 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, <code class="literal">NULL</code> isreturned. This function must be called while holding the <em class="parameter"><code>queue</code></em>'slock.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>queue</code></em> :</span></td><td> a <a href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> data from the queue or <code class="literal">NULL</code>, when no data isavailable immediately.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2896113"></a><h3><a name="g-async-queue-timed-pop-unlocked"></a>g_async_queue_timed_pop_unlocked ()</h3><a class="indexterm" name="id2896124"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_timed_pop_unlocked (<a href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue, <a 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>,<code class="literal">NULL</code> is returned. This function must be called while holding the<em class="parameter"><code>queue</code></em>'s lock.</p><p>To easily calculate <em class="parameter"><code>end_time</code></em> a combination of <a href="glib-Date-and-Time-Functions.html#g-get-current-time"><code class="function">g_get_current_time()</code></a>and <a 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><span class="term"><em class="parameter"><code>queue</code></em> :</span></td><td> a <a href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><span class="term"><em class="parameter"><code>end_time</code></em> :</span></td><td> a <a href="glib-Date-and-Time-Functions.html#GTimeVal"><span class="type">GTimeVal</span></a>, determining the final time.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> data from the queue or <code class="literal">NULL</code>, 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="id2896290"></a><h3><a name="g-async-queue-length-unlocked"></a>g_async_queue_length_unlocked ()</h3><a class="indexterm" name="id2896301"></a><pre class="programlisting"><a href="glib-Basic-Types.html#gint">gint</a> g_async_queue_length_unlocked (<a href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue);</pre><p>Returns the length of the queue, negative values mean waitingthreads, positive values mean available entries in the<em class="parameter"><code>queue</code></em>. Actually this function returns the number of data items inthe queue minus the number of waiting threads. Thus a return valueof 0 could mean 'n' entries in the queue and 'n' thread waiting.That can happen due to locking of the queue or due toscheduling. This function must be called while holding the <em class="parameter"><code>queue</code></em>'slock.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>queue</code></em> :</span></td><td> a <a href="glib-Asynchronous-Queues.html#GAsyncQueue"><span class="type">GAsyncQueue</span></a>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></td><td> the length of the <em class="parameter"><code>queue</code></em>.</td></tr></tbody></table></div></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-Thread-Pools.html"><b><< Thread Pools</b></a></td><td align="right"><a accesskey="n" href="glib-Dynamic-Loading-of-Modules.html"><b>Dynamic Loading of Modules >></b></a></td></tr></table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -