[tracker/compilation-warnings: 12/13] tracker-writeback: Use g_(mutex|cond)_(init|clear) if GLib >= 2.31



commit b88e722887092c2330436eb3e4f1b9d37ddd5409
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Fri Dec 16 13:00:48 2011 +0100

    tracker-writeback: Use g_(mutex|cond)_(init|clear) if GLib >= 2.31
    
    Since 2.31, g_mutex_new(), g_mutex_free(), g_cond_new(), g_cond_free() are
    deprecated.

 src/tracker-writeback/tracker-writeback.c |   59 ++++++++++++++++++++++++++--
 1 files changed, 54 insertions(+), 5 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback.c b/src/tracker-writeback/tracker-writeback.c
index bae1769..afc4f17 100644
--- a/src/tracker-writeback/tracker-writeback.c
+++ b/src/tracker-writeback/tracker-writeback.c
@@ -63,8 +63,13 @@ typedef struct {
 	guint shutdown_timeout;
 	GSource *shutdown_source;
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	GCond initialization_cond;
+	GMutex initialization_mutex, mutex;
+#else
 	GCond *initialization_cond;
 	GMutex *initialization_mutex, *mutex;
+#endif
 	GError *initialization_error;
 
 	guint initialized : 1;
@@ -147,9 +152,15 @@ tracker_controller_finalize (GObject *object)
 	g_main_loop_unref (priv->main_loop);
 	g_main_context_unref (priv->context);
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_cond_clear (&priv->initialization_cond);
+	g_mutex_clear (&priv->initialization_mutex);
+	g_mutex_clear (&priv->mutex);
+#else
 	g_cond_free (priv->initialization_cond);
 	g_mutex_free (priv->initialization_mutex);
 	g_mutex_free (priv->mutex);
+#endif
 
 	G_OBJECT_CLASS (tracker_controller_parent_class)->finalize (object);
 }
@@ -212,7 +223,11 @@ task_cancellable_cancelled_cb (GCancellable  *cancellable,
 
 	priv = data->controller->priv;
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_mutex_lock (&priv->mutex);
+#else
 	g_mutex_lock (priv->mutex);
+#endif
 
 	if (priv->current == data) {
 		g_message ("Cancelled writeback task for '%s' was currently being "
@@ -221,7 +236,11 @@ task_cancellable_cancelled_cb (GCancellable  *cancellable,
 		_exit (0);
 	}
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_mutex_unlock (&priv->mutex);
+#else
 	g_mutex_unlock (priv->mutex);
+#endif
 }
 
 
@@ -390,9 +409,15 @@ tracker_controller_init (TrackerController *controller)
 	g_signal_connect (priv->storage, "mount-point-removed",
 	                  G_CALLBACK (mount_point_removed_cb), controller);
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_cond_init (&priv->initialization_cond);
+	g_mutex_init (&priv->initialization_mutex);
+	g_mutex_init (&priv->mutex);
+#else
 	priv->initialization_cond = g_cond_new ();
 	priv->initialization_mutex = g_mutex_new ();
 	priv->mutex = g_mutex_new ();
+#endif
 }
 
 static void
@@ -437,9 +462,15 @@ perform_writeback_cb (gpointer user_data)
 
 	tracker_dbus_request_end (data->request, NULL);
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_mutex_lock (&priv->mutex);
+	priv->current = NULL;
+	g_mutex_unlock (&priv->mutex);
+#else
 	g_mutex_lock (priv->mutex);
 	priv->current = NULL;
 	g_mutex_unlock (priv->mutex);
+#endif
 
 	writeback_data_free (data);
 
@@ -476,9 +507,15 @@ io_writeback_job (GIOSchedulerJob *job,
 	gboolean handled = FALSE;
 	GList *writeback_handlers;
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_mutex_lock (&priv->mutex);
+	priv->current = data;
+	g_mutex_unlock (&priv->mutex);
+#else
 	g_mutex_lock (priv->mutex);
 	priv->current = data;
 	g_mutex_unlock (priv->mutex);
+#endif
 
 	writeback_handlers = data->writeback_handlers;
 
@@ -660,15 +697,23 @@ controller_notify_main_thread (TrackerController *controller,
 
 	priv = controller->priv;
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_mutex_lock (&priv->initialization_mutex);
+#else
 	g_mutex_lock (priv->initialization_mutex);
+#endif
 
 	priv->initialized = TRUE;
 	priv->initialization_error = error;
 
 	/* Notify about the initialization */
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_cond_signal (&priv->initialization_cond);
+	g_mutex_unlock (&priv->initialization_mutex);
+#else
 	g_cond_signal (priv->initialization_cond);
-
 	g_mutex_unlock (priv->initialization_mutex);
+#endif
 }
 
 static void
@@ -892,13 +937,17 @@ tracker_controller_start (TrackerController  *controller,
 #endif /* THREAD_ENABLE_TRACE */
 
 	/* Wait for the controller thread to notify initialization */
+#if GLIB_CHECK_VERSION (2,31,0)
+	g_mutex_lock (&priv->initialization_mutex);
+	while (!priv->initialized)
+		g_cond_wait (&priv->initialization_cond, &priv->initialization_mutex);
+	g_mutex_unlock (&priv->initialization_mutex);
+#else
 	g_mutex_lock (priv->initialization_mutex);
-
-	while (!priv->initialized) {
+	while (!priv->initialized)
 		g_cond_wait (priv->initialization_cond, priv->initialization_mutex);
-	}
-
 	g_mutex_unlock (priv->initialization_mutex);
+#endif
 
 	/* If there was any error resulting from initialization, propagate it */
 	if (priv->initialization_error != NULL) {



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