[tracker/fix-deprecations] libtracker-data, tracker-writeback: Switched all g_io_scheduler_push_job() --> g_task_run_in_thread(



commit 5137f378165f80dd68113c82a597b0dbf0e92dcf
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Sep 3 17:46:48 2013 +0100

    libtracker-data, tracker-writeback: Switched all g_io_scheduler_push_job() --> g_task_run_in_thread()
    
    g_io_scheduler_push_job() is deprecated

 src/libtracker-data/tracker-db-backup.c   |   26 ++++++++++++++++----------
 src/tracker-writeback/tracker-writeback.c |   23 +++++++++++++----------
 2 files changed, 29 insertions(+), 20 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-backup.c b/src/libtracker-data/tracker-db-backup.c
index c0985ee..8a506e5 100644
--- a/src/libtracker-data/tracker-db-backup.c
+++ b/src/libtracker-data/tracker-db-backup.c
@@ -77,15 +77,16 @@ backup_info_free (gpointer user_data)
 
        g_clear_error (&info->error);
 
-       g_free (info);
+       g_slice_free (BackupInfo, info);
 }
 
-static gboolean
-backup_job (GIOSchedulerJob *job,
-            GCancellable    *cancellable,
-            gpointer         user_data)
+static void
+backup_job (GTask        *task,
+            gpointer      source_object,
+            gpointer      task_data,
+            GCancellable *cancellable)
 {
-       BackupInfo *info = user_data;
+       BackupInfo *info = task_data;
 
        const gchar *src_path;
        GFile *parent_file, *temp_file;
@@ -163,8 +164,6 @@ backup_job (GIOSchedulerJob *job,
 
        g_idle_add_full (G_PRIORITY_DEFAULT, perform_callback, info,
                         backup_info_free);
-
-       return FALSE;
 }
 
 void
@@ -173,7 +172,10 @@ tracker_db_backup_save (GFile                   *destination,
                         gpointer                 user_data,
                         GDestroyNotify           destroy)
 {
-       BackupInfo *info = g_new0 (BackupInfo, 1);
+       GTask *task;
+       BackupInfo *info;
+
+       info = g_slice_new0 (BackupInfo);
 
        info->destination = g_object_ref (destination);
 
@@ -181,6 +183,10 @@ tracker_db_backup_save (GFile                   *destination,
        info->user_data = user_data;
        info->destroy = destroy;
 
-       g_io_scheduler_push_job (backup_job, info, NULL, 0, NULL);
+       task = g_task_new (NULL, NULL, NULL, NULL);
+
+       g_task_set_task_data (task, info, NULL);
+       g_task_run_in_thread (task, backup_job);
+       g_object_unref (task);
 }
 
diff --git a/src/tracker-writeback/tracker-writeback.c b/src/tracker-writeback/tracker-writeback.c
index c527197..1f65552 100644
--- a/src/tracker-writeback/tracker-writeback.c
+++ b/src/tracker-writeback/tracker-writeback.c
@@ -496,12 +496,13 @@ sparql_rdf_types_match (const gchar * const *module_types,
        return FALSE;
 }
 
-static gboolean
-io_writeback_job (GIOSchedulerJob *job,
-                  GCancellable    *cancellable,
-                  gpointer         user_data)
+static void
+io_writeback_job (GTask        *task,
+                  gpointer      source_object,
+                  gpointer      task_data,
+                  GCancellable *cancellable)
 {
-       WritebackData *data = user_data;
+       WritebackData *data = task_data;
        TrackerControllerPrivate *priv = data->controller->priv;
        GError *error = NULL;
        gboolean handled = FALSE;
@@ -543,8 +544,6 @@ io_writeback_job (GIOSchedulerJob *job,
        }
 
        g_idle_add (perform_writeback_cb, data);
-
-       return FALSE;
 }
 
 static void
@@ -563,7 +562,6 @@ handle_method_call_perform_writeback (TrackerController     *controller,
        GStrv rdf_types;
        gchar *rdf_type = NULL;
        GList *writeback_handlers = NULL;
-       WritebackData *data;
 
        priv = controller->priv;
 
@@ -618,6 +616,10 @@ handle_method_call_perform_writeback (TrackerController     *controller,
        }
 
        if (writeback_handlers != NULL) {
+               WritebackData *data;
+               GTask *task;
+
+               task = g_task_new (controller, NULL, NULL, NULL);
                data = writeback_data_new (controller,
                                           writeback_handlers,
                                           priv->connection,
@@ -626,8 +628,9 @@ handle_method_call_perform_writeback (TrackerController     *controller,
                                           invocation,
                                           request);
 
-               g_io_scheduler_push_job (io_writeback_job, data, NULL, 0,
-                                        data->cancellable);
+               g_task_set_task_data (task, data, NULL /*(GDestroyNotify) writeback_data_free */);
+               g_task_run_in_thread (task, io_writeback_job);
+               g_object_unref (task);
        } else {
                g_dbus_method_invocation_return_error (invocation,
                                                       TRACKER_DBUS_ERROR,


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