[tracker/tracker-store] Some improvements for the push plugins
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker/tracker-store] Some improvements for the push plugins
- Date: Tue, 23 Jun 2009 13:13:40 -0400 (EDT)
commit 3e7421c566e6fe0d0ae15aec6e7c670203e97220
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Jun 23 19:12:48 2009 +0200
Some improvements for the push plugins
src/plugins/evolution/tracker-evolution-plugin.c | 5 +-
.../evolution/tracker-evolution-registrar.c | 91 ++------------------
src/plugins/kmail/tracker-kmail-registrar.c | 91 ++------------------
3 files changed, 16 insertions(+), 171 deletions(-)
---
diff --git a/src/plugins/evolution/tracker-evolution-plugin.c b/src/plugins/evolution/tracker-evolution-plugin.c
index dbdc9f1..2fe6277 100644
--- a/src/plugins/evolution/tracker-evolution-plugin.c
+++ b/src/plugins/evolution/tracker-evolution-plugin.c
@@ -591,8 +591,7 @@ start_many_handler (void)
{
/* We just slow it down to 'once per second' (for now, we can tweak this
* afterward, of course, but once per second seems to work great) */
-
- g_timeout_add_seconds_full (G_PRIORITY_LOW, 1,
+ g_timeout_add_seconds_full (G_PRIORITY_LOW, 1,
many_idle_handler,
NULL,
many_idle_destroy);
@@ -760,7 +759,7 @@ introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self,
count++;
}
- if (count > MAX_BEFORE_SEND) {
+ if (count >= MAX_BEFORE_SEND) {
/* Yield per MAX_BEFORE_SEND. This function is
* called as a result of a DBus call, so it runs
diff --git a/src/plugins/evolution/tracker-evolution-registrar.c b/src/plugins/evolution/tracker-evolution-registrar.c
index 57b633c..e61ee32 100644
--- a/src/plugins/evolution/tracker-evolution-registrar.c
+++ b/src/plugins/evolution/tracker-evolution-registrar.c
@@ -77,16 +77,6 @@ enum {
};
-typedef struct {
- guint modseq, item_no, reached;
- gchar *subject;
- GStrv predicates;
- GStrv values;
-} QueuedSet;
-
-static GQueue *many_queue = NULL;
-#define QUEUED_SETS_PER_MAINLOOP 2
-
static GType tracker_evolution_push_registrar_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (TrackerEvolutionRegistrar, tracker_evolution_registrar, G_TYPE_OBJECT)
@@ -662,60 +652,6 @@ tracker_evolution_registrar_set (TrackerEvolutionRegistrar *object,
tracker_dbus_request_success (request_id);
}
-static void
-queued_set_free (QueuedSet *queued_set)
-{
- g_free (queued_set->subject);
- g_strfreev (queued_set->values);
- g_strfreev (queued_set->predicates);
- g_slice_free (QueuedSet, queued_set);
-}
-
-static gboolean
-many_idle_handler (gpointer user_data)
-{
- guint i;
- QueuedSet *queued_set = GUINT_TO_POINTER (1);
- TrackerEvolutionRegistrar *object = user_data;
-
- for (i = 0; i < QUEUED_SETS_PER_MAINLOOP && queued_set ; i++) {
- queued_set = g_queue_pop_head (many_queue);
-
- if (queued_set) {
- perform_set (object,
- queued_set->subject,
- queued_set->predicates,
- queued_set->values);
-
- if (queued_set->item_no == queued_set->reached) {
- tracker_store_queue_commit (on_commit,
- GUINT_TO_POINTER (queued_set->modseq),
- NULL);
- }
-
- queued_set_free (queued_set);
- }
- }
-
- return (gboolean) queued_set;
-}
-
-static void
-many_idle_destroy (gpointer user_data)
-{
- g_queue_free (many_queue);
- many_queue = NULL;
- g_object_unref (user_data);
-}
-
-static void
-start_many_handler (TrackerEvolutionRegistrar *object)
-{
- g_idle_add_full (G_PRIORITY_LOW,
- many_idle_handler,
- g_object_ref (object),
- many_idle_destroy);
-}
void
tracker_evolution_registrar_set_many (TrackerEvolutionRegistrar *object,
@@ -728,7 +664,6 @@ tracker_evolution_registrar_set_many (TrackerEvolutionRegistrar *object,
{
guint request_id;
guint len, i = 0;
- gboolean start_handler = FALSE;
request_id = tracker_dbus_get_next_request_id ();
@@ -745,29 +680,17 @@ tracker_evolution_registrar_set_many (TrackerEvolutionRegistrar *object,
"DBus request to set many: 'Evolution' "
"'%d'", len);
- if (!many_queue) {
- many_queue = g_queue_new ();
- start_handler = TRUE;
- }
-
while (subjects[i] != NULL) {
- QueuedSet *queued_set = g_slice_new (QueuedSet);
-
- queued_set->subject = g_strdup (subjects[i]);
- queued_set->predicates = g_strdupv (g_ptr_array_index (predicates, i));
- queued_set->values = g_strdupv (g_ptr_array_index (values, i));
- queued_set->modseq = modseq;
- queued_set->item_no = i;
- queued_set->reached = len - 1;
-
- g_queue_push_tail (many_queue, queued_set);
-
+ perform_set (object,
+ subjects[i],
+ g_ptr_array_index (predicates, i),
+ g_ptr_array_index (values, i));
i++;
}
- if (start_handler) {
- start_many_handler (object);
- }
+ tracker_store_queue_commit (on_commit,
+ GUINT_TO_POINTER (modseq),
+ NULL);
dbus_g_method_return (context);
diff --git a/src/plugins/kmail/tracker-kmail-registrar.c b/src/plugins/kmail/tracker-kmail-registrar.c
index 06533f3..56e5f65 100644
--- a/src/plugins/kmail/tracker-kmail-registrar.c
+++ b/src/plugins/kmail/tracker-kmail-registrar.c
@@ -75,16 +75,6 @@ enum {
};
-typedef struct {
- guint modseq, item_no, reached;
- gchar *subject;
- GStrv predicates;
- GStrv values;
-} QueuedSet;
-
-static GQueue *many_queue = NULL;
-#define QUEUED_SETS_PER_MAINLOOP 2
-
static GType tracker_kmail_push_registrar_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (TrackerKMailRegistrar, tracker_kmail_registrar, G_TYPE_OBJECT)
@@ -425,61 +415,6 @@ tracker_kmail_registrar_set (TrackerKMailRegistrar *object,
tracker_dbus_request_success (request_id);
}
-static void
-queued_set_free (QueuedSet *queued_set)
-{
- g_free (queued_set->subject);
- g_strfreev (queued_set->values);
- g_strfreev (queued_set->predicates);
- g_slice_free (QueuedSet, queued_set);
-}
-
-static gboolean
-many_idle_handler (gpointer user_data)
-{
- guint i;
- QueuedSet *queued_set = GUINT_TO_POINTER (1);
- TrackerKMailRegistrar *object = user_data;
-
- for (i = 0; i < QUEUED_SETS_PER_MAINLOOP && queued_set ; i++) {
- queued_set = g_queue_pop_head (many_queue);
-
- if (queued_set) {
- perform_set (object,
- queued_set->subject,
- queued_set->predicates,
- queued_set->values);
-
- if (queued_set->item_no == queued_set->reached) {
- tracker_store_queue_commit (on_commit,
- GUINT_TO_POINTER (queued_set->modseq),
- NULL);
- }
-
- queued_set_free (queued_set);
- }
- }
-
- return (gboolean) queued_set;
-}
-
-static void
-many_idle_destroy (gpointer user_data)
-{
- g_queue_free (many_queue);
- many_queue = NULL;
- g_object_unref (user_data);
-}
-
-static void
-start_many_handler (TrackerKMailRegistrar *object)
-{
- g_idle_add_full (G_PRIORITY_LOW,
- many_idle_handler,
- g_object_ref (object),
- many_idle_destroy);
-}
-
void
tracker_kmail_registrar_set_many (TrackerKMailRegistrar *object,
const GStrv subjects,
@@ -508,29 +443,17 @@ tracker_kmail_registrar_set_many (TrackerKMailRegistrar *object,
"DBus request to set many: 'KMail' "
"'%d'", len);
- if (!many_queue) {
- many_queue = g_queue_new ();
- start_handler = TRUE;
- }
-
while (subjects[i] != NULL) {
- QueuedSet *queued_set = g_slice_new (QueuedSet);
-
- queued_set->subject = g_strdup (subjects[i]);
- queued_set->predicates = g_strdupv (g_ptr_array_index (predicates, i));
- queued_set->values = g_strdupv (g_ptr_array_index (values, i));
- queued_set->modseq = modseq;
- queued_set->item_no = i;
- queued_set->reached = len - 1;
-
- g_queue_push_tail (many_queue, queued_set);
-
+ perform_set (object,
+ subjects[i],
+ g_ptr_array_index (predicates, i),
+ g_ptr_array_index (values, i));
i++;
}
- if (start_handler) {
- start_many_handler (object);
- }
+ tracker_store_queue_commit (on_commit,
+ GUINT_TO_POINTER (modseq),
+ NULL);
dbus_g_method_return (context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]