📄 glib-asynchronous-queues.html
字号:
<p>This function is called while holding the <em class="parameter"><code>queue</code></em>'s lock.</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="id2912745"></a><h3><a name="g-async-queue-pop-unlocked"></a>g_async_queue_pop_unlocked ()</h3><a class="indexterm" name="id2912759"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_pop_unlocked (<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. 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><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="id2912838"></a><h3><a name="g-async-queue-try-pop-unlocked"></a>g_async_queue_try_pop_unlocked ()</h3><a class="indexterm" name="id2912851"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_try_pop_unlocked (<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. 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><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="id2912952"></a><h3><a name="g-async-queue-timed-pop-unlocked"></a>g_async_queue_timed_pop_unlocked ()</h3><a class="indexterm" name="id2912965"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> g_async_queue_timed_pop_unlocked (<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. 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 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="id2913138"></a><h3><a name="g-async-queue-length-unlocked"></a>g_async_queue_length_unlocked ()</h3><a class="indexterm" name="id2913152"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a> g_async_queue_length_unlocked (<a class="link" 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><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 length of the <em class="parameter"><code>queue</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2913248"></a><h3><a name="g-async-queue-sort-unlocked"></a>g_async_queue_sort_unlocked ()</h3><a class="indexterm" name="id2913264"></a><pre class="programlisting">void g_async_queue_sort_unlocked (<a class="link" href="glib-Asynchronous-Queues.html#GAsyncQueue">GAsyncQueue</a> *queue, <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>Sorts <em class="parameter"><code>queue</code></em> using <em class="parameter"><code>func</code></em>. </p><p>This function is called while holding the <em class="parameter"><code>queue</code></em>'s lock.</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>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></div><div class="refsect1" lang="en"><a name="id2913437"></a><div class="refsect2" lang="en"><a name="id2913438"></a></div><hr><div class="refsect2" lang="en"><a name="id2913439"></a></div></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -