diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2019-05-20 11:07:54 +0000 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2019-05-20 11:07:54 +0000 |
commit | 13da7e5c2e0fbcb319b288ba6b0d846118de2079 (patch) | |
tree | 8ea53ad7600791bf16df50ee39cb875bc5c804a7 | |
parent | 522e74982e752f85771dc9ba7f9d9518ef11752d (diff) | |
parent | b465cb158b54c6eb0a1e923f88641da65a9f176b (diff) | |
download | glib-13da7e5c2e0fbcb319b288ba6b0d846118de2079.tar.gz |
Merge branch 'wip/ignazp/gtask-wait-time-fix' into 'master'
gtask: fix task_wait_time estimation
Closes #1683
See merge request GNOME/glib!644
-rw-r--r-- | gio/gtask.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gio/gtask.c b/gio/gtask.c index f6c89c974..9950bb36b 100644 --- a/gio/gtask.c +++ b/gio/gtask.c @@ -626,11 +626,14 @@ static gint tasks_running; * The base and multiplier below gives us 10 extra threads after about * a second of blocking, 30 after 5 seconds, 100 after a minute, and * 200 after 20 minutes. + * + * We specify maximum pool size of 330 to increase the waiting time up + * to around 30 minutes. */ #define G_TASK_POOL_SIZE 10 #define G_TASK_WAIT_TIME_BASE 100000 #define G_TASK_WAIT_TIME_MULTIPLIER 1.03 -#define G_TASK_WAIT_TIME_MAX (30 * 60 * 1000000) +#define G_TASK_WAIT_TIME_MAX_POOL_SIZE 330 static void g_task_init (GTask *task) @@ -1366,7 +1369,7 @@ g_task_thread_setup (void) if (tasks_running == G_TASK_POOL_SIZE) task_wait_time = G_TASK_WAIT_TIME_BASE; - else if (tasks_running > G_TASK_POOL_SIZE && task_wait_time < G_TASK_WAIT_TIME_MAX) + else if (tasks_running > G_TASK_POOL_SIZE && tasks_running < G_TASK_WAIT_TIME_MAX_POOL_SIZE) task_wait_time *= G_TASK_WAIT_TIME_MULTIPLIER; if (tasks_running >= G_TASK_POOL_SIZE) @@ -1388,6 +1391,9 @@ g_task_thread_cleanup (void) else if (tasks_running + tasks_pending < G_TASK_POOL_SIZE) g_source_set_ready_time (task_pool_manager, -1); + if (tasks_running > G_TASK_POOL_SIZE && tasks_running < G_TASK_WAIT_TIME_MAX_POOL_SIZE) + task_wait_time /= G_TASK_WAIT_TIME_MULTIPLIER; + tasks_running--; g_mutex_unlock (&task_pool_mutex); g_private_set (&task_private, GUINT_TO_POINTER (FALSE)); |