⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-thread-pools.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<td> a <a class="link" href="glib-Thread-Pools.html#GThreadPool"><span class="type">GThreadPool</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>immediate</code></em>&#160;:</span></p></td><td> should <em class="parameter"><code>pool</code></em> shut down immediately?</td></tr><tr><td><p><span class="term"><em class="parameter"><code>wait_</code></em>&#160;:</span></p></td><td> should the function wait for all tasks to be finished?</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2906458"></a><h3><a name="g-thread-pool-set-max-unused-threads"></a>g_thread_pool_set_max_unused_threads ()</h3><a class="indexterm" name="id2906472"></a><pre class="programlisting">void                g_thread_pool_set_max_unused_threads                                                        (<a class="link" href="glib-Basic-Types.html#gint">gint</a> max_threads);</pre><p>Sets the maximal number of unused threads to <em class="parameter"><code>max_threads</code></em>. If<em class="parameter"><code>max_threads</code></em> is -1, no limit is imposed on the number of unusedthreads.</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>max_threads</code></em>&#160;:</span></p></td><td> maximal number of unused threads</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2906537"></a><h3><a name="g-thread-pool-get-max-unused-threads"></a>g_thread_pool_get_max_unused_threads ()</h3><a class="indexterm" name="id2906551"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint">gint</a>                g_thread_pool_get_max_unused_threads                                                        (void);</pre><p>Returns the maximal allowed number of unused threads.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the maximal number of unused threads</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2906594"></a><h3><a name="g-thread-pool-get-num-unused-threads"></a>g_thread_pool_get_num_unused_threads ()</h3><a class="indexterm" name="id2906607"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a>               g_thread_pool_get_num_unused_threads                                                        (void);</pre><p>Returns the number of currently unused threads.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the number of currently unused threads</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2906649"></a><h3><a name="g-thread-pool-stop-unused-threads"></a>g_thread_pool_stop_unused_threads ()</h3><a class="indexterm" name="id2906664"></a><pre class="programlisting">void                g_thread_pool_stop_unused_threads   (void);</pre><p>Stops all currently unused threads. This does not change themaximal number of unused threads. This function can be used toregularly stop all unused threads e.g. from <a class="link" href="glib-The-Main-Event-Loop.html#g-timeout-add"><code class="function">g_timeout_add()</code></a>.</p><p></p></div><hr><div class="refsect2" lang="en"><a name="id2906701"></a><h3><a name="g-thread-pool-set-sort-function"></a>g_thread_pool_set_sort_function ()</h3><a class="indexterm" name="id2906717"></a><pre class="programlisting">void                g_thread_pool_set_sort_function     (<a class="link" href="glib-Thread-Pools.html#GThreadPool">GThreadPool</a> *pool,                                                         <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>Sets the function used to sort the list of tasks. This allows thetasks to be processed by a priority determined by <em class="parameter"><code>func</code></em>, and notjust in the order in which they were added to the pool.</p><p>Note, if the maximum number of threads is more than 1, the orderthat threads are executed can not be guranteed 100%. Threads arescheduled by the operating system and are executed at random. Itcannot be assumed that threads are executed in the order they arecreated.</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>pool</code></em>&#160;:</span></p></td><td> a <a class="link" href="glib-Thread-Pools.html#GThreadPool"><span class="type">GThreadPool</span></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td><td> the <a class="link" href="glib-Doubly-Linked-Lists.html#GCompareDataFunc"><span class="type">GCompareDataFunc</span></a> used to sort the list of tasks.     This function is passed two tasks. It should return    0 if the order in which they are handled does not matter,     a negative value if the first task should be processed before    the second or a positive value if the second task should be     processed first.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>user_data</code></em>&#160;:</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="id2906862"></a><h3><a name="g-thread-pool-set-max-idle-time"></a>g_thread_pool_set_max_idle_time ()</h3><a class="indexterm" name="id2906878"></a><pre class="programlisting">void                g_thread_pool_set_max_idle_time     (<a class="link" href="glib-Basic-Types.html#guint">guint</a> interval);</pre><p>This function will set the maximum <em class="parameter"><code>interval</code></em> that a thread waitingin the pool for new tasks can be idle for before beingstopped. This function is similar to calling<a class="link" href="glib-Thread-Pools.html#g-thread-pool-stop-unused-threads"><code class="function">g_thread_pool_stop_unused_threads()</code></a> on a regular timeout, except,this is done on a per thread basis.    </p><p>By setting <em class="parameter"><code>interval</code></em> to 0, idle threads will not be stopped. This function makes use of <a class="link" href="glib-Asynchronous-Queues.html#g-async-queue-timed-pop"><code class="function">g_async_queue_timed_pop()</code></a> using<em class="parameter"><code>interval</code></em>.</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>interval</code></em>&#160;:</span></p></td><td> the maximum <em class="parameter"><code>interval</code></em> (1/1000ths of a second) a thread    can be idle. </td></tr></tbody></table></div><p class="since">Since  2.10</p></div><hr><div class="refsect2" lang="en"><a name="id2906991"></a><h3><a name="g-thread-pool-get-max-idle-time"></a>g_thread_pool_get_max_idle_time ()</h3><a class="indexterm" name="id2907007"></a><pre class="programlisting"><a class="link" href="glib-Basic-Types.html#guint">guint</a>               g_thread_pool_get_max_idle_time     (void);</pre><p>This function will return the maximum <em class="parameter"><code>interval</code></em> that a thread willwait in the thread pool for new tasks before being stopped.</p><p>If this function returns 0, threads waiting in the thread pool fornew work are not stopped.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td> the maximum <em class="parameter"><code>interval</code></em> to wait for new tasks in the    thread pool before stopping the thread (1/1000ths of a second). </td></tr></tbody></table></div><p class="since">Since  2.10</p></div></div><div class="refsect1" lang="en"><a name="id2907076"></a><h2>See Also</h2><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a class="link" href="glib-Threads.html#GThread"><span class="type">GThread</span></a></span></p></td><td><p>GLib thread system.</p></td></tr></tbody></table></div><p></p></div><div class="refsect1" lang="en"><a name="id2907105"></a><div class="refsect2" lang="en"><a name="id2907106"></a></div><hr><div class="refsect2" lang="en"><a name="id2907107"></a></div></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -