[tracker/class-signal: 22/50] tracker-store, libtracker-data: Pending vs. ready arrays, to control transactions
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/class-signal: 22/50] tracker-store, libtracker-data: Pending vs. ready arrays, to control transactions
- Date: Fri, 27 Aug 2010 11:49:53 +0000 (UTC)
commit fcaf55dcdfa73473c4f8bde8ea14c36af829d679
Author: Philip Van Hoof <philip codeminded be>
Date: Fri Aug 20 18:32:57 2010 +0200
tracker-store, libtracker-data: Pending vs. ready arrays, to control transactions
src/libtracker-data/tracker-class.c | 102 ++++++++++++++++++++++++---------
src/tracker-store/tracker-resources.c | 27 ++++++++-
2 files changed, 99 insertions(+), 30 deletions(-)
---
diff --git a/src/libtracker-data/tracker-class.c b/src/libtracker-data/tracker-class.c
index 5dc9973..676d268 100644
--- a/src/libtracker-data/tracker-class.c
+++ b/src/libtracker-data/tracker-class.c
@@ -46,12 +46,24 @@ struct _TrackerClassPrivate {
GArray *last_domain_indexes;
struct {
- GArray *sub_pred_ids;
- GArray *object_ids;
+ struct {
+ GArray *sub_pred_ids;
+ GArray *object_ids;
+ } pending;
+ struct {
+ GArray *sub_pred_ids;
+ GArray *object_ids;
+ } ready;
} deletes;
struct {
- GArray *sub_pred_ids;
- GArray *object_ids;
+ struct {
+ GArray *sub_pred_ids;
+ GArray *object_ids;
+ } pending;
+ struct {
+ GArray *sub_pred_ids;
+ GArray *object_ids;
+ } ready;
} inserts;
};
@@ -81,11 +93,15 @@ tracker_class_init (TrackerClass *service)
priv->domain_indexes = g_array_new (TRUE, TRUE, sizeof (TrackerProperty *));
priv->last_domain_indexes = NULL;
- priv->deletes.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
- priv->deletes.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->deletes.pending.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+ priv->deletes.pending.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->deletes.ready.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+ priv->deletes.ready.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
- priv->inserts.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
- priv->inserts.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->inserts.pending.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+ priv->inserts.pending.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
+ priv->inserts.ready.sub_pred_ids = g_array_new (FALSE, FALSE, sizeof (gint64));
+ priv->inserts.ready.object_ids = g_array_new (FALSE, FALSE, sizeof (gint));
/* Make GET_PRIV working */
service->priv = priv;
@@ -104,11 +120,15 @@ class_finalize (GObject *object)
g_array_free (priv->super_classes, TRUE);
g_array_free (priv->domain_indexes, TRUE);
- g_array_free (priv->deletes.sub_pred_ids, TRUE);
- g_array_free (priv->deletes.object_ids, TRUE);
+ g_array_free (priv->deletes.pending.sub_pred_ids, TRUE);
+ g_array_free (priv->deletes.pending.object_ids, TRUE);
+ g_array_free (priv->deletes.ready.sub_pred_ids, TRUE);
+ g_array_free (priv->deletes.ready.object_ids, TRUE);
- g_array_free (priv->inserts.sub_pred_ids, TRUE);
- g_array_free (priv->inserts.object_ids, TRUE);
+ g_array_free (priv->inserts.pending.sub_pred_ids, TRUE);
+ g_array_free (priv->inserts.pending.object_ids, TRUE);
+ g_array_free (priv->inserts.ready.sub_pred_ids, TRUE);
+ g_array_free (priv->inserts.ready.object_ids, TRUE);
if (priv->last_domain_indexes)
g_array_free (priv->last_domain_indexes, TRUE);
@@ -433,7 +453,7 @@ tracker_class_has_insert_events (TrackerClass *class)
priv = GET_PRIV (class);
- return (priv->inserts.sub_pred_ids->len > 0);
+ return (priv->inserts.ready.sub_pred_ids->len > 0);
}
gboolean
@@ -445,7 +465,7 @@ tracker_class_has_delete_events (TrackerClass *class)
priv = GET_PRIV (class);
- return (priv->deletes.sub_pred_ids->len > 0);
+ return (priv->deletes.ready.sub_pred_ids->len > 0);
}
void
@@ -461,14 +481,14 @@ tracker_class_foreach_insert_event (TrackerClass *class,
priv = GET_PRIV (class);
- for (i = 0; i < priv->inserts.sub_pred_ids->len; i++) {
+ for (i = 0; i < priv->inserts.ready.sub_pred_ids->len; i++) {
gint subject_id, pred_id, object_id;
gint64 sub_pred_id;
- sub_pred_id = g_array_index (priv->inserts.sub_pred_ids, gint64, i);
+ sub_pred_id = g_array_index (priv->inserts.ready.sub_pred_ids, gint64, i);
pred_id = sub_pred_id & 0xffffffff;
subject_id = sub_pred_id >> 32;
- object_id = g_array_index (priv->inserts.object_ids, gint, i);
+ object_id = g_array_index (priv->inserts.ready.object_ids, gint, i);
foreach (subject_id, pred_id, object_id, user_data);
}
@@ -487,14 +507,14 @@ tracker_class_foreach_delete_event (TrackerClass *class,
priv = GET_PRIV (class);
- for (i = 0; i < priv->deletes.sub_pred_ids->len; i++) {
+ for (i = 0; i < priv->deletes.ready.sub_pred_ids->len; i++) {
gint subject_id, pred_id, object_id;
gint64 sub_pred_id;
- sub_pred_id = g_array_index (priv->deletes.sub_pred_ids, gint64, i);
+ sub_pred_id = g_array_index (priv->deletes.ready.sub_pred_ids, gint64, i);
pred_id = sub_pred_id & 0xffffffff;
subject_id = sub_pred_id >> 32;
- object_id = g_array_index (priv->deletes.object_ids, gint, i);
+ object_id = g_array_index (priv->deletes.ready.object_ids, gint, i);
foreach (subject_id, pred_id, object_id, user_data);
}
@@ -508,11 +528,37 @@ tracker_class_reset_events (TrackerClass *class)
g_return_if_fail (TRACKER_IS_CLASS (class));
priv = GET_PRIV (class);
- g_array_set_size (priv->deletes.sub_pred_ids, 0);
- g_array_set_size (priv->deletes.object_ids, 0);
+ /* Move */
+ g_array_insert_vals (priv->deletes.ready.object_ids,
+ priv->deletes.ready.object_ids->len,
+ priv->deletes.pending.object_ids->data,
+ priv->deletes.pending.object_ids->len);
+
+ g_array_insert_vals (priv->deletes.ready.sub_pred_ids,
+ priv->deletes.ready.sub_pred_ids->len,
+ priv->deletes.pending.sub_pred_ids->data,
+ priv->deletes.pending.sub_pred_ids->len);
+
+ /* Reset */
+ g_array_set_size (priv->deletes.pending.sub_pred_ids, 0);
+ g_array_set_size (priv->deletes.pending.object_ids, 0);
+
+
+ /* Move */
+ g_array_insert_vals (priv->inserts.ready.object_ids,
+ priv->inserts.ready.object_ids->len,
+ priv->inserts.pending.object_ids->data,
+ priv->inserts.pending.object_ids->len);
+
+ g_array_insert_vals (priv->inserts.ready.sub_pred_ids,
+ priv->inserts.ready.sub_pred_ids->len,
+ priv->inserts.pending.sub_pred_ids->data,
+ priv->inserts.pending.sub_pred_ids->len);
+
+ /* Reset */
+ g_array_set_size (priv->inserts.pending.sub_pred_ids, 0);
+ g_array_set_size (priv->inserts.pending.object_ids, 0);
- g_array_set_size (priv->inserts.sub_pred_ids, 0);
- g_array_set_size (priv->inserts.object_ids, 0);
}
static void
@@ -551,8 +597,8 @@ tracker_class_add_insert_event (TrackerClass *class,
g_return_if_fail (TRACKER_IS_CLASS (class));
priv = GET_PRIV (class);
- insert_vals_into_arrays (priv->inserts.sub_pred_ids,
- priv->inserts.object_ids,
+ insert_vals_into_arrays (priv->inserts.pending.sub_pred_ids,
+ priv->inserts.pending.object_ids,
subject_id,
pred_id,
object_id);
@@ -569,8 +615,8 @@ tracker_class_add_delete_event (TrackerClass *class,
g_return_if_fail (TRACKER_IS_CLASS (class));
priv = GET_PRIV (class);
- insert_vals_into_arrays (priv->deletes.sub_pred_ids,
- priv->deletes.object_ids,
+ insert_vals_into_arrays (priv->deletes.pending.sub_pred_ids,
+ priv->deletes.pending.object_ids,
subject_id,
pred_id,
object_id);
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index 71aaa9f..2389c72 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -81,6 +81,7 @@ enum {
typedef struct {
DBusConnection *connection;
+ guint class_signal_timeout;
} TrackerResourcesPrivate;
typedef struct {
@@ -584,11 +585,13 @@ emit_class_signal (TrackerResources *self,
dbus_connection_send (priv->connection, message, NULL);
dbus_message_unref (message);
+
+ tracker_class_reset_events (class);
}
}
-static void
-on_statements_committed (gpointer user_data)
+static gboolean
+on_emit_class_signal (gpointer user_data)
{
TrackerResources *resources = user_data;
GHashTable *writebacks;
@@ -606,6 +609,21 @@ on_statements_committed (gpointer user_data)
emit_class_signal (user_data, class);
}
+ return TRUE;
+}
+
+static void
+on_statements_committed (gpointer user_data)
+{
+ TrackerResources *resources = user_data;
+ GHashTable *writebacks;
+ TrackerResourcesPrivate *priv;
+ GHashTableIter iter;
+ gpointer key, value;
+
+ priv = TRACKER_RESOURCES_GET_PRIVATE (resources);
+
+ /* Class signal feature */
tracker_events_reset ();
/* Writeback feature */
@@ -669,6 +687,8 @@ tracker_resources_prepare (TrackerResources *object)
tracker_data_add_delete_statement_callback (on_statement_deleted, object);
tracker_data_add_commit_statement_callback (on_statements_committed, object);
tracker_data_add_rollback_statement_callback (on_statements_rolled_back, object);
+
+ priv->class_signal_timeout = g_timeout_add_seconds (1, on_emit_class_signal, object);
}
static void
@@ -683,6 +703,9 @@ tracker_resources_finalize (GObject *object)
tracker_data_remove_commit_statement_callback (on_statements_committed, object);
tracker_data_remove_rollback_statement_callback (on_statements_rolled_back, object);
+ if (priv->class_signal_timeout != 0)
+ g_source_remove (priv->class_signal_timeout);
+
dbus_connection_unref (priv->connection);
G_OBJECT_CLASS (tracker_resources_parent_class)->finalize (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]