[tracker/compilation-warnings: 4/13] tracker-extract: use g_thread_try_new() if GLib >= 2.31



commit c73d3040911cd3bc81612460341263f0439dc894
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Fri Dec 16 11:26:34 2011 +0100

    tracker-extract: use g_thread_try_new() if GLib >= 2.31
    
    Since 2.31, g_thread_create() is deprecated.

 src/tracker-extract/tracker-controller.c |   14 ++++++++++++++
 src/tracker-extract/tracker-extract.c    |   19 +++++++++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/tracker-extract/tracker-controller.c b/src/tracker-extract/tracker-controller.c
index 6c059fc..a2b0a0f 100644
--- a/src/tracker-extract/tracker-controller.c
+++ b/src/tracker-extract/tracker-controller.c
@@ -991,10 +991,24 @@ tracker_controller_start (TrackerController  *controller,
 {
 	TrackerControllerPrivate *priv;
 
+#if GLIB_CHECK_VERSION (2,31,0)
+	GThread *thread;
+
+	thread = g_thread_try_new ("controller",
+	                           tracker_controller_thread_func,
+	                           controller,
+	                           error);
+	if (!thread)
+		return FALSE;
+
+	/* We don't want to join it, so just unref the GThread */
+	g_thread_unref (thread);
+#else
 	if (!g_thread_create (tracker_controller_thread_func,
 	                      controller, FALSE, error)) {
 		return FALSE;
 	}
+#endif
 
 	priv = controller->priv;
 
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index ce78e1b..91b1d32 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -732,6 +732,24 @@ dispatch_task_cb (TrackerExtractTask *task)
 			 */
 			async_queue = g_async_queue_new ();
 
+#if GLIB_CHECK_VERSION (2,31,0)
+			{
+				GThread *thread;
+
+				thread = g_thread_try_new ("single",
+				                           (GThreadFunc) single_thread_get_metadata,
+				                           g_async_queue_ref (async_queue),
+				                           &error);
+				if (!thread) {
+					g_simple_async_result_take_error ((GSimpleAsyncResult *) task->res, error);
+					g_simple_async_result_complete_in_idle ((GSimpleAsyncResult *) task->res);
+					extract_task_free (task);
+					return FALSE;
+				}
+				/* We won't join the thread, so just unref it here */
+				g_object_unref (thread);
+			}
+#else
 			g_thread_create ((GThreadFunc) single_thread_get_metadata,
 			                 g_async_queue_ref (async_queue),
 			                 FALSE, &error);
@@ -744,6 +762,7 @@ dispatch_task_cb (TrackerExtractTask *task)
 
 				return FALSE;
 			}
+#endif
 
 			g_hash_table_insert (priv->single_thread_extractors, module, async_queue);
 		}



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