[maemo-commits] [maemo-commits] r16185 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Sep 23 14:27:31 EEST 2008
Author: pvanhoof
Date: 2008-09-23 14:27:30 +0300 (Tue, 23 Sep 2008)
New Revision: 16185

Modified:
   projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c
Log:
2008-09-23  Philip Van Hoof  <pvanhoof at gnome.org>

	* daemon/thumbnailer.c: Adding a thread for large tasks



Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog	2008-09-23 10:20:49 UTC (rev 16184)
+++ projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog	2008-09-23 11:27:30 UTC (rev 16185)
@@ -1,6 +1,6 @@
 2008-09-23  Philip Van Hoof  <pvanhoof at gnome.org>
 
-	* daemon/thumbnailer.c: Adding a thread whenever a large task arrives
+	* daemon/thumbnailer.c: Adding a thread for large tasks
 
 2008-09-20  Philip Van Hoof  <pvanhoof at gnome.org>
 

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c	2008-09-23 10:20:49 UTC (rev 16184)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c	2008-09-23 11:27:30 UTC (rev 16185)
@@ -52,7 +52,8 @@
 typedef struct {
 	Manager *manager;
 	GHashTable *plugins;
-	GThreadPool *pool;
+	GThreadPool *large_pool;
+	GThreadPool *normal_pool;
 	GMutex *mutex;
 	GList *tasks;
 } ThumbnailerPrivate;
@@ -195,20 +196,14 @@
 	task->urls = g_strdupv (urls);
 	task->poolmax = FALSE;
 
-	if (g_strv_length (urls) > 10) {
-		guint max = g_thread_pool_get_max_threads (priv->pool);
-		guint cur = g_thread_pool_get_num_threads (priv->pool);
 
-		if (max <= cur && max < 20) {
-			g_thread_pool_set_max_threads (priv->pool, max+1, NULL);
-			task->poolmax = TRUE;
-		}
-	}
-
 	g_mutex_lock (priv->mutex);
 	g_list_foreach (priv->tasks, (GFunc) mark_unqueued, (gpointer) handle_to_unqueue);
 	priv->tasks = g_list_prepend (priv->tasks, task);
-	g_thread_pool_push (priv->pool, task, NULL);
+	if (g_strv_length (urls) > 10)
+		g_thread_pool_push (priv->large_pool, task, NULL);
+	else
+		g_thread_pool_push (priv->normal_pool, task, NULL);
 	g_mutex_unlock (priv->mutex);
 
 	dbus_g_method_return (context, num);
@@ -398,11 +393,6 @@
 
 unqueued:
 
-	if (task->poolmax) {
-		guint max = g_thread_pool_get_max_threads (priv->pool);
-		g_thread_pool_set_max_threads (priv->pool, max-1, NULL);
-	}
-
 	g_object_unref (task->object);
 	g_strfreev (task->urls);
 	g_slice_free (WorkTask, task);
@@ -633,7 +623,8 @@
 {
 	ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object);
 
-	g_thread_pool_free (priv->pool, TRUE, TRUE);
+	g_thread_pool_free (priv->normal_pool, TRUE, TRUE);
+	g_thread_pool_free (priv->large_pool, TRUE, TRUE);
 
 	g_object_unref (priv->manager);
 	g_hash_table_unref (priv->plugins);
@@ -767,11 +758,14 @@
 
 	/* We could increase the amount of threads to add some parallelism */
 
-	priv->pool = g_thread_pool_new ((GFunc) do_the_work,NULL,1,TRUE,NULL);
+	priv->large_pool = g_thread_pool_new ((GFunc) do_the_work,NULL,1,TRUE,NULL);
+	priv->normal_pool = g_thread_pool_new ((GFunc) do_the_work,NULL,1,TRUE,NULL);
 
 	/* This sort function makes the pool a LIFO */
 
-	g_thread_pool_set_sort_function (priv->pool, pool_sort_compare, NULL);
+	g_thread_pool_set_sort_function (priv->large_pool, pool_sort_compare, NULL);
+	g_thread_pool_set_sort_function (priv->normal_pool, pool_sort_compare, NULL);
+
 }
 
 


More information about the maemo-commits mailing list