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

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Sep 23 13:20:51 EEST 2008
Author: pvanhoof
Date: 2008-09-23 13:20:49 +0300 (Tue, 23 Sep 2008)
New Revision: 16184

Modified:
   projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog
   projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c
Log:
Adding a thread when a large item arrives

Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog	2008-09-23 07:22:43 UTC (rev 16183)
+++ projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog	2008-09-23 10:20:49 UTC (rev 16184)
@@ -1,3 +1,7 @@
+2008-09-23  Philip Van Hoof  <pvanhoof at gnome.org>
+
+	* daemon/thumbnailer.c: Adding a thread whenever a large task arrives
+
 2008-09-20  Philip Van Hoof  <pvanhoof at gnome.org>
 
 	* thumbs/hildon-thumbnail-factory.c

Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c
===================================================================
--- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c	2008-09-23 07:22:43 UTC (rev 16183)
+++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c	2008-09-23 10:20:49 UTC (rev 16184)
@@ -143,6 +143,7 @@
 	Thumbnailer *object;
 	GStrv urls;
 	guint num;
+	gboolean poolmax;
 	gboolean unqueued;
 } WorkTask;
 
@@ -192,7 +193,18 @@
 	task->num = ++num;
 	task->object = g_object_ref (object);
 	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);
@@ -386,6 +398,11 @@
 
 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);


More information about the maemo-commits mailing list