[tracker/async-queries-due: 1/6] tracker-store: Do not use GStaticPrivate for thread-independent data



commit 5b6197eb550160ec395cd65b09dd4518021765c9
Author: Jürg Billeter <j bitron ch>
Date:   Thu Apr 15 15:32:52 2010 +0200

    tracker-store: Do not use GStaticPrivate for thread-independent data

 src/tracker-store/tracker-events.c    |   23 +++--------------------
 src/tracker-store/tracker-writeback.c |   21 +++------------------
 2 files changed, 6 insertions(+), 38 deletions(-)
---
diff --git a/src/tracker-store/tracker-events.c b/src/tracker-store/tracker-events.c
index beda952..fed1377 100644
--- a/src/tracker-store/tracker-events.c
+++ b/src/tracker-store/tracker-events.c
@@ -32,15 +32,13 @@ typedef struct {
 	GArray *events;
 } EventsPrivate;
 
-static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
+static EventsPrivate *private;
 
 static void
 tracker_events_add_allow (const gchar *rdf_class)
 {
-	EventsPrivate *private;
 	TrackerClass *cl;
 
-	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
 	cl = tracker_ontologies_get_class_by_uri (rdf_class);
@@ -87,10 +85,7 @@ tracker_events_insert (const gchar *uri,
                        GPtrArray *rdf_types,
                        TrackerDBusEventsType type)
 {
-	EventsPrivate *private;
-
 	g_return_if_fail (rdf_types || type != TRACKER_DBUS_EVENTS_TYPE_UPDATE);
-	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
 	if (rdf_types && type == TRACKER_DBUS_EVENTS_TYPE_UPDATE) {
@@ -125,10 +120,8 @@ tracker_event_destroy (TrackerEvent *event)
 void
 tracker_events_reset (void)
 {
-	EventsPrivate *private;
 	guint i;
 
-	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
 	if (private->events) {
@@ -144,9 +137,6 @@ tracker_events_reset (void)
 GArray *
 tracker_events_get_pending (void)
 {
-	EventsPrivate *private;
-
-	private = g_static_private_get (&private_key);
 	g_return_val_if_fail (private != NULL, NULL);
 
 	return private->events;
@@ -162,16 +152,11 @@ free_private (EventsPrivate *private)
 void
 tracker_events_init (TrackerNotifyClassGetter callback)
 {
-	EventsPrivate *private;
 	GStrv          classes_to_signal;
 	gint           i, count;
 
 	private = g_new0 (EventsPrivate, 1);
 
-	g_static_private_set (&private_key,
-	                      private,
-	                      (GDestroyNotify) free_private);
-
 	private->allowances = g_hash_table_new (g_direct_hash, g_direct_equal);
 
 	private->events = NULL;
@@ -196,12 +181,10 @@ tracker_events_init (TrackerNotifyClassGetter callback)
 void
 tracker_events_shutdown (void)
 {
-	EventsPrivate *private;
-
-	private = g_static_private_get (&private_key);
 	if (private != NULL) {
 		tracker_events_reset ();
-		g_static_private_set (&private_key, NULL, NULL);
+		free_private (private);
+		private = NULL;
 	} else {
 		g_warning ("tracker_events already shutdown");
 	}
diff --git a/src/tracker-store/tracker-writeback.c b/src/tracker-store/tracker-writeback.c
index 629e79a..62646b3 100644
--- a/src/tracker-store/tracker-writeback.c
+++ b/src/tracker-store/tracker-writeback.c
@@ -31,7 +31,7 @@ typedef struct {
 	GHashTable *events;
 } WritebackPrivate;
 
-static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
+static WritebackPrivate *private;
 
 static GStrv
 copy_rdf_types (GPtrArray *rdf_types)
@@ -55,8 +55,6 @@ tracker_writeback_check (const gchar *graph,
                          const gchar *object,
                          GPtrArray   *rdf_types)
 {
-	WritebackPrivate *private;
-
 	/* When graph is NULL, the graph is the default one. We only do
 	 * writeback reporting in the default graph (update queries that
 	 * aren't coming from the miner)
@@ -67,7 +65,6 @@ tracker_writeback_check (const gchar *graph,
 		return;
 	}
 
-	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
 	if (g_hash_table_lookup (private->allowances, predicate)) {
@@ -86,9 +83,6 @@ tracker_writeback_check (const gchar *graph,
 void
 tracker_writeback_reset (void)
 {
-	WritebackPrivate *private;
-
-	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
 	if (private->events) {
@@ -100,9 +94,6 @@ tracker_writeback_reset (void)
 GHashTable *
 tracker_writeback_get_pending (void)
 {
-	WritebackPrivate *private;
-
-	private = g_static_private_get (&private_key);
 	g_return_val_if_fail (private != NULL, NULL);
 
 	return private->events;
@@ -121,17 +112,13 @@ free_private (gpointer user_data)
 void
 tracker_writeback_init (TrackerWritebackGetPredicatesFunc func)
 {
-	WritebackPrivate *private;
 	GStrv predicates_to_signal;
 	gint i, count;
 
-	private = g_static_private_get (&private_key);
 	g_return_if_fail (private == NULL);
 
 	private = g_new0 (WritebackPrivate, 1);
 
-	g_static_private_set (&private_key, private, free_private);
-
 	private->allowances = g_hash_table_new_full (g_str_hash,
 	                                             g_str_equal,
 	                                             (GDestroyNotify) g_free,
@@ -165,11 +152,9 @@ tracker_writeback_init (TrackerWritebackGetPredicatesFunc func)
 void
 tracker_writeback_shutdown (void)
 {
-	WritebackPrivate *private;
-
-	private = g_static_private_get (&private_key);
 	g_return_if_fail (private != NULL);
 
 	tracker_writeback_reset ();
-	g_static_private_set (&private_key, NULL, NULL);
+	free_private (private);
+	private = NULL;
 }



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