mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 23:58:54 +02:00
gthreadpool: set default max_unused_threads and max_idle_time values
GThreadPool defaulted to 0 for max_unused_threads (meaning thread-pool threads would exit immediately if there was not already another task waiting for them), and 0 for max_idle_time (meaning unused threads would linger forever, though this is only relevant if you changed max_unused_threads). However, GIOScheduler changed the global defaults to 2 and 15*1000, respectively, arguing that these were more useful defaults. And they are, so let's use them. https://bugzilla.gnome.org/show_bug.cgi?id=661767
This commit is contained in:
@@ -113,12 +113,6 @@ init_scheduler (gpointer arg)
|
|||||||
g_thread_pool_set_sort_function (job_thread_pool,
|
g_thread_pool_set_sort_function (job_thread_pool,
|
||||||
g_io_job_compare,
|
g_io_job_compare,
|
||||||
NULL);
|
NULL);
|
||||||
/* It's kinda weird that this is a global setting
|
|
||||||
* instead of per threadpool. However, we really
|
|
||||||
* want to cache some threads, but not keep around
|
|
||||||
* those threads forever. */
|
|
||||||
g_thread_pool_set_max_idle_time (15 * 1000);
|
|
||||||
g_thread_pool_set_max_unused_threads (2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@@ -110,9 +110,9 @@ static gint wakeup_thread_serial = 0;
|
|||||||
/* Here all unused threads are waiting */
|
/* Here all unused threads are waiting */
|
||||||
static GAsyncQueue *unused_thread_queue = NULL;
|
static GAsyncQueue *unused_thread_queue = NULL;
|
||||||
static gint unused_threads = 0;
|
static gint unused_threads = 0;
|
||||||
static gint max_unused_threads = 0;
|
static gint max_unused_threads = 2;
|
||||||
static gint kill_unused_threads = 0;
|
static gint kill_unused_threads = 0;
|
||||||
static guint max_idle_time = 0;
|
static guint max_idle_time = 15 * 1000;
|
||||||
|
|
||||||
static void g_thread_pool_queue_push_unlocked (GRealThreadPool *pool,
|
static void g_thread_pool_queue_push_unlocked (GRealThreadPool *pool,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
@@ -829,6 +829,8 @@ g_thread_pool_wakeup_and_stop_all (GRealThreadPool *pool)
|
|||||||
* Sets the maximal number of unused threads to @max_threads.
|
* Sets the maximal number of unused threads to @max_threads.
|
||||||
* If @max_threads is -1, no limit is imposed on the number
|
* If @max_threads is -1, no limit is imposed on the number
|
||||||
* of unused threads.
|
* of unused threads.
|
||||||
|
*
|
||||||
|
* The default value is 2.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
g_thread_pool_set_max_unused_threads (gint max_threads)
|
g_thread_pool_set_max_unused_threads (gint max_threads)
|
||||||
@@ -964,8 +966,7 @@ g_thread_pool_set_sort_function (GThreadPool *pool,
|
|||||||
*
|
*
|
||||||
* By setting @interval to 0, idle threads will not be stopped.
|
* By setting @interval to 0, idle threads will not be stopped.
|
||||||
*
|
*
|
||||||
* This function makes use of g_async_queue_timed_pop () using
|
* The default value is 15000 (15 seconds).
|
||||||
* @interval.
|
|
||||||
*
|
*
|
||||||
* Since: 2.10
|
* Since: 2.10
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user