[gnome-builder] build-pipeline: chain root cancellable per-task



commit 1c2d12c618c331edf95f4c6e4e63b82ee37dd8ea
Author: Christian Hergert <chergert redhat com>
Date:   Mon Dec 18 15:24:41 2017 -0800

    build-pipeline: chain root cancellable per-task
    
    Now that we have dzl_cancellable_chain(), we can use a custom
    GCancellable for each async operation, and chain the root
    cancellable to it.
    
    This makes things easier from our perspective of giving an
    escape hatch API like _ide_build_pipeline_cancel(), while also
    allowing tasks to be cancelled via caller state.

 src/libide/buildsystem/ide-build-pipeline.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/libide/buildsystem/ide-build-pipeline.c b/src/libide/buildsystem/ide-build-pipeline.c
index dea822a..0e97937 100644
--- a/src/libide/buildsystem/ide-build-pipeline.c
+++ b/src/libide/buildsystem/ide-build-pipeline.c
@@ -1540,10 +1540,14 @@ ide_build_pipeline_build_async (IdeBuildPipeline    *self,
                                 gpointer             user_data)
 {
   g_autoptr(GTask) task = NULL;
+  g_autoptr(GCancellable) local_cancellable = NULL;
   TaskData *task_data;
 
   IDE_ENTRY;
 
+  if (cancellable == NULL)
+    cancellable = local_cancellable = g_cancellable_new ();
+
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_source_tag (task, ide_build_pipeline_build_async);
   g_task_set_priority (task, G_PRIORITY_LOW);
@@ -2729,6 +2733,7 @@ ide_build_pipeline_clean_async (IdeBuildPipeline    *self,
                                 gpointer             user_data)
 {
   g_autoptr(GTask) task = NULL;
+  g_autoptr(GCancellable) local_cancellable = NULL;
   g_autoptr(GPtrArray) stages = NULL;
   IdeBuildPhase min_phase = IDE_BUILD_PHASE_FINAL;
   IdeBuildPhase phase_mask;
@@ -2740,6 +2745,9 @@ ide_build_pipeline_clean_async (IdeBuildPipeline    *self,
   g_assert (IDE_IS_BUILD_PIPELINE (self));
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
 
+  if (cancellable == NULL)
+    cancellable = local_cancellable = g_cancellable_new ();
+
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_priority (task, G_PRIORITY_LOW);
   g_task_set_source_tag (task, ide_build_pipeline_clean_async);
@@ -2967,6 +2975,7 @@ ide_build_pipeline_rebuild_async (IdeBuildPipeline    *self,
                                   gpointer             user_data)
 {
   g_autoptr(GTask) task = NULL;
+  g_autoptr(GCancellable) local_cancellable = NULL;
   TaskData *td;
 
   IDE_ENTRY;
@@ -2975,6 +2984,9 @@ ide_build_pipeline_rebuild_async (IdeBuildPipeline    *self,
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
   g_return_if_fail ((phase & ~IDE_BUILD_PHASE_MASK) == 0);
 
+  if (cancellable == NULL)
+    cancellable = local_cancellable = g_cancellable_new ();
+
   task = g_task_new (self, cancellable, callback, user_data);
   g_task_set_priority (task, G_PRIORITY_LOW);
   g_task_set_source_tag (task, ide_build_pipeline_rebuild_async);


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