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

📄 thread_pools.sgml

📁 一套linux glib源代码
💻 SGML
字号:
<!-- ##### SECTION Title ##### -->Thread Pools<!-- ##### SECTION Short_Description ##### -->pools of threads to execute work concurrently.<!-- ##### SECTION Long_Description ##### --><para>Sometimes you wish to asyncronously fork out the execution of work andcontinue working in your own thread. If that will happen often, theoverhead of starting and destroying a thread each time might be tohigh. In such cases reusing already started threads seems like a goodidea. And it indeed is, but implementing this can be tedious anderror-prone.</para><para>Therefore GLib provides thread pools for your convenience. An addedadvantage is, that the threads can be shared between the differentsubsystems of your program, when they are using GLib.</para><para>To create a new thread pool, you use g_thread_pool_new(). It isdestroyed by g_thread_pool_free().</para><para>If you want to execute a certain task within a thread pool, you callg_thread_pool_push().</para><para>To get the current number of running threads you callg_thread_pool_get_num_threads(). To get the number of stillunprocessed tasks you call g_thread_pool_unprocessed(). To control themaximal number of threads for a thread pool, you useg_thread_pool_get_max_threads() and g_thread_pool_set_max_threads().</para><para>Finally you can control the number of unused threads, that are keptalive by GLib for future use. The current number can be fetched withg_thread_pool_get_num_unused_threads(). The maximal number can becontrolled by g_thread_pool_get_max_unused_threads() andg_thread_pool_set_max_unused_threads(). All currently unused threadscan be stopped by calling g_thread_pool_stop_unused_threads().</para><!-- ##### SECTION See_Also ##### --><para><variablelist><varlistentry><term>#GThread</term><listitem><para>GLib thread system.</para></listitem></varlistentry></variablelist></para><!-- ##### SECTION Stability_Level ##### --><!-- ##### STRUCT GThreadPool ##### --><para>The #GThreadPool struct represents a thread pool. It has six publicread-only members, but the underlying struct is bigger, so you must not copythis struct.</para>@func: the function to execute in the threads of this pool@user_data: the user data for the threads of this pool@exclusive: are all threads exclusive to this pool<!-- ##### FUNCTION g_thread_pool_new ##### --><para></para>@func: @user_data: @max_threads: @exclusive: @error: @Returns: <!-- ##### FUNCTION g_thread_pool_push ##### --><para></para>@pool: @data: @error: <!-- ##### FUNCTION g_thread_pool_set_max_threads ##### --><para></para>@pool: @max_threads: @error: <!-- ##### FUNCTION g_thread_pool_get_max_threads ##### --><para></para>@pool: @Returns: <!-- ##### FUNCTION g_thread_pool_get_num_threads ##### --><para></para>@pool: @Returns: <!-- ##### FUNCTION g_thread_pool_unprocessed ##### --><para></para>@pool: @Returns: <!-- ##### FUNCTION g_thread_pool_free ##### --><para></para>@pool: @immediate: @wait_: <!-- ##### FUNCTION g_thread_pool_set_max_unused_threads ##### --><para></para>@max_threads: <!-- ##### FUNCTION g_thread_pool_get_max_unused_threads ##### --><para></para>@Returns: <!-- ##### FUNCTION g_thread_pool_get_num_unused_threads ##### --><para></para>@Returns: <!-- ##### FUNCTION g_thread_pool_stop_unused_threads ##### --><para></para><!-- ##### FUNCTION g_thread_pool_set_sort_function ##### --><para></para>@pool: @func: @user_data: <!-- ##### FUNCTION g_thread_pool_set_max_idle_time ##### --><para></para>@interval: <!-- ##### FUNCTION g_thread_pool_get_max_idle_time ##### --><para></para>@Returns: 

⌨️ 快捷键说明

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