[tracker/async-queries] TrackerDBInterfacePool: Add job prioritization.



commit 91f62e2330deba18b99fab420e2b7d6fb816ead7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Apr 13 16:41:45 2010 +0200

    TrackerDBInterfacePool: Add job prioritization.

 src/libtracker-db/tracker-db-manager.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-manager.c b/src/libtracker-db/tracker-db-manager.c
index 41c86fc..8d310c7 100644
--- a/src/libtracker-db/tracker-db-manager.c
+++ b/src/libtracker-db/tracker-db-manager.c
@@ -1265,6 +1265,23 @@ pool_job_destroy (PoolJob *job)
 	g_slice_free (PoolJob, job);
 }
 
+static gint
+compare_pool_jobs_func (gconstpointer a,
+                        gconstpointer b,
+                        gpointer      user_data)
+{
+	PoolJob *job_a = (PoolJob *) a;
+	PoolJob *job_b = (PoolJob *) b;
+
+	if (job_a->priority < job_b->priority) {
+		return -1;
+	} else if (job_a->priority > job_b->priority) {
+		return 1;
+	} else {
+		return 0;
+	}
+}
+
 static void
 interface_pool_dispatch_cb (gpointer data,
                             gpointer user_data)
@@ -1398,6 +1415,9 @@ tracker_db_interface_pool_init (TrackerDBInterfacePool *pool)
 	priv->interface_pool = g_thread_pool_new (interface_pool_dispatch_cb,
 	                                          NULL, 10,
 	                                          FALSE, NULL);
+	g_thread_pool_set_sort_function (priv->interface_pool,
+	                                 compare_pool_jobs_func,
+	                                 NULL);
 }
 
 TrackerDBInterfacePool *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]