[tracker/class-signal-perf-impr] tracker-store: Use a cache of tracker:notify classes in tracker-events.c
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/class-signal-perf-impr] tracker-store: Use a cache of tracker:notify classes in tracker-events.c
- Date: Tue, 15 Mar 2011 12:32:42 +0000 (UTC)
commit b7c591d8c4fcdeec7cc876419a7c7bec0424f0aa
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Mar 15 13:32:12 2011 +0100
tracker-store: Use a cache of tracker:notify classes in tracker-events.c
src/tracker-store/tracker-events.c | 60 +++++++++++++++++++----------
src/tracker-store/tracker-events.h | 39 ++++++++++---------
src/tracker-store/tracker-events.vapi | 1 +
src/tracker-store/tracker-resources.vala | 20 +++------
4 files changed, 67 insertions(+), 53 deletions(-)
---
diff --git a/src/tracker-store/tracker-events.c b/src/tracker-store/tracker-events.c
index cd13e67..7fa7fea 100644
--- a/src/tracker-store/tracker-events.c
+++ b/src/tracker-store/tracker-events.c
@@ -29,6 +29,7 @@
typedef struct {
gboolean frozen;
guint total;
+ GPtrArray *cache;
} EventsPrivate;
static EventsPrivate *private;
@@ -112,20 +113,14 @@ tracker_events_add_delete (gint graph_id,
void
tracker_events_reset_pending (void)
{
- TrackerClass **classes;
- guint length = 0;
guint i;
g_return_if_fail (private != NULL);
- classes = tracker_ontologies_get_classes (&length);
-
- for (i = 0; i < length; i++) {
- TrackerClass *class = classes[i];
+ for (i = 0; i < private->cache->len; i++) {
+ TrackerClass *class = g_ptr_array_index (private->cache, i);
- if (tracker_class_get_notify (class)) {
- tracker_class_reset_pending_events (class);
- }
+ tracker_class_reset_pending_events (class);
}
private->frozen = FALSE;
@@ -142,31 +137,54 @@ tracker_events_freeze (void)
static void
free_private (EventsPrivate *private)
{
- TrackerClass **classes;
- guint length = 0;
guint i;
- classes = tracker_ontologies_get_classes (&length);
+ for (i = 0; i < private->cache->len; i++) {
+ TrackerClass *class = g_ptr_array_index (private->cache, i);
- for (i = 0; i < length; i++) {
- TrackerClass *class = classes[i];
-
- if (tracker_class_get_notify (class)) {
- tracker_class_reset_pending_events (class);
+ tracker_class_reset_pending_events (class);
- /* Perhaps hurry an emit of the ready events here? We're shutting down,
- * so I guess we're not required to do that here ... ? */
- tracker_class_reset_ready_events (class);
- }
+ /* Perhaps hurry an emit of the ready events here? We're shutting down,
+ * so I guess we're not required to do that here ... ? */
+ tracker_class_reset_ready_events (class);
}
+ g_ptr_array_unref (private->cache);
+
g_free (private);
}
+TrackerClass **
+tracker_events_get_classes (guint *length)
+{
+ g_return_val_if_fail (private != NULL, NULL);
+
+ *length = private->cache->len;
+
+ return (TrackerClass **) (private->cache->pdata);
+}
+
void
tracker_events_init (void)
{
+ TrackerClass **classes;
+ guint length = 0, i;
+
private = g_new0 (EventsPrivate, 1);
+
+ classes = tracker_ontologies_get_classes (&length);
+
+ private->cache = g_ptr_array_sized_new (length);
+ g_ptr_array_set_free_func (private->cache, (GDestroyNotify) g_object_unref);
+
+ for (i = 0; i < length; i++) {
+ TrackerClass *class = classes[i];
+
+ if (tracker_class_get_notify (class)) {
+ g_ptr_array_add (private->cache, g_object_ref (class));
+ }
+ }
+
}
void
diff --git a/src/tracker-store/tracker-events.h b/src/tracker-store/tracker-events.h
index dfeb754..26f5ccb 100644
--- a/src/tracker-store/tracker-events.h
+++ b/src/tracker-store/tracker-events.h
@@ -30,25 +30,26 @@ G_BEGIN_DECLS
typedef GStrv (*TrackerNotifyClassGetter) (void);
-void tracker_events_init (void);
-void tracker_events_shutdown (void);
-void tracker_events_add_insert (gint graph_id,
- gint subject_id,
- const gchar *subject,
- gint pred_id,
- gint object_id,
- const gchar *object,
- GPtrArray *rdf_types);
-void tracker_events_add_delete (gint graph_id,
- gint subject_id,
- const gchar *subject,
- gint pred_id,
- gint object_id,
- const gchar *object,
- GPtrArray *rdf_types);
-guint tracker_events_get_total (gboolean and_reset);
-void tracker_events_reset_pending (void);
-void tracker_events_freeze (void);
+void tracker_events_init (void);
+void tracker_events_shutdown (void);
+void tracker_events_add_insert (gint graph_id,
+ gint subject_id,
+ const gchar *subject,
+ gint pred_id,
+ gint object_id,
+ const gchar *object,
+ GPtrArray *rdf_types);
+void tracker_events_add_delete (gint graph_id,
+ gint subject_id,
+ const gchar *subject,
+ gint pred_id,
+ gint object_id,
+ const gchar *object,
+ GPtrArray *rdf_types);
+guint tracker_events_get_total (gboolean and_reset);
+void tracker_events_reset_pending (void);
+void tracker_events_freeze (void);
+TrackerClass** tracker_events_get_classes (guint *length);
G_END_DECLS
diff --git a/src/tracker-store/tracker-events.vapi b/src/tracker-store/tracker-events.vapi
index 154eceb..f9f7787 100644
--- a/src/tracker-store/tracker-events.vapi
+++ b/src/tracker-store/tracker-events.vapi
@@ -27,5 +27,6 @@ namespace Tracker {
public uint get_total (bool and_reset);
public void reset_pending ();
public void freeze ();
+ public unowned Class[] get_classes ();
}
}
diff --git a/src/tracker-store/tracker-resources.vala b/src/tracker-store/tracker-resources.vala
index 1d4b780..f679282 100644
--- a/src/tracker-store/tracker-resources.vala
+++ b/src/tracker-store/tracker-resources.vala
@@ -217,11 +217,9 @@ public class Tracker.Resources : Object {
bool on_emit_signals () {
bool had_any = false;
- foreach (var cl in Tracker.Ontologies.get_classes ()) {
- if (cl.notify) {
- if (emit_graph_updated (cl)) {
- had_any = true;
- }
+ foreach (var cl in Tracker.Events.get_classes ()) {
+ if (emit_graph_updated (cl)) {
+ had_any = true;
}
}
@@ -268,10 +266,8 @@ public class Tracker.Resources : Object {
void on_statements_committed (bool start_timer) {
/* Class signal feature */
- foreach (var cl in Tracker.Ontologies.get_classes ()) {
- if (cl.notify) {
- cl.transact_events ();
- }
+ foreach (var cl in Tracker.Events.get_classes ()) {
+ cl.transact_events ();
}
if (start_timer && signal_timeout == 0) {
@@ -291,10 +287,8 @@ public class Tracker.Resources : Object {
/* Check for whether we need an immediate emit */
if (Tracker.Events.get_total (false) > GRAPH_UPDATED_IMMEDIATE_EMIT_AT) {
- foreach (var cl in Tracker.Ontologies.get_classes ()) {
- if (cl.notify) {
- emit_graph_updated (cl);
- }
+ foreach (var cl in Tracker.Events.get_classes ()) {
+ emit_graph_updated (cl);
}
/* Reset counter */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]