[gnome-builder] ctags: port accessories to IdeTask
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] ctags: port accessories to IdeTask
- Date: Wed, 21 Mar 2018 22:02:39 +0000 (UTC)
commit 0498899c0aab5015f37a98c973748305fdf70622
Author: Christian Hergert <chergert redhat com>
Date: Wed Mar 21 15:02:06 2018 -0700
ctags: port accessories to IdeTask
This doesn't yet port the service to IdeTask, as that is more complex due
to using DzlTaskCache.
src/plugins/ctags/ide-ctags-builder.c | 23 ++++++++++----------
src/plugins/ctags/ide-ctags-index.c | 36 +++++++++++++++----------------
src/plugins/ctags/ide-ctags-symbol-node.c | 22 +++++++++----------
3 files changed, 41 insertions(+), 40 deletions(-)
---
diff --git a/src/plugins/ctags/ide-ctags-builder.c b/src/plugins/ctags/ide-ctags-builder.c
index 7008aa958..dc1d67546 100644
--- a/src/plugins/ctags/ide-ctags-builder.c
+++ b/src/plugins/ctags/ide-ctags-builder.c
@@ -253,7 +253,7 @@ finish_subprocess:
}
static void
-ide_ctags_builder_build_worker (GTask *task,
+ide_ctags_builder_build_worker (IdeTask *task,
gpointer source_object,
gpointer task_data_ptr,
GCancellable *cancellable)
@@ -265,7 +265,7 @@ ide_ctags_builder_build_worker (GTask *task,
IDE_ENTRY;
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_CTAGS_BUILDER (source_object));
g_assert (G_IS_FILE (task_data->directory));
@@ -281,7 +281,7 @@ ide_ctags_builder_build_worker (GTask *task,
task_data->recursive,
cancellable);
- g_task_return_boolean (task, TRUE);
+ ide_task_return_boolean (task, TRUE);
IDE_EXIT;
}
@@ -295,7 +295,7 @@ ide_ctags_builder_build_async (IdeTagsBuilder *builder,
gpointer user_data)
{
IdeCtagsBuilder *self = (IdeCtagsBuilder *)builder;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
g_autoptr(GSettings) settings = NULL;
g_autofree gchar *destination_path = NULL;
g_autofree gchar *relative_path = NULL;
@@ -328,11 +328,12 @@ ide_ctags_builder_build_async (IdeTagsBuilder *builder,
destination_path = ide_context_cache_filename (context, "ctags", relative_path, NULL);
task_data->destination = g_file_new_for_path (destination_path);
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, ide_ctags_builder_build_async);
- g_task_set_priority (task, G_PRIORITY_LOW);
- g_task_set_task_data (task, task_data, build_task_data_free);
- ide_thread_pool_push_task (IDE_THREAD_POOL_INDEXER, task, ide_ctags_builder_build_worker);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_source_tag (task, ide_ctags_builder_build_async);
+ ide_task_set_priority (task, G_PRIORITY_LOW + 200);
+ ide_task_set_task_data (task, task_data, build_task_data_free);
+ ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
+ ide_task_run_in_thread (task, ide_ctags_builder_build_worker);
IDE_EXIT;
}
@@ -347,9 +348,9 @@ ide_ctags_builder_build_finish (IdeTagsBuilder *builder,
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_CTAGS_BUILDER (builder), FALSE);
- g_return_val_if_fail (G_IS_TASK (result), FALSE);
+ g_return_val_if_fail (IDE_IS_TASK (result), FALSE);
- ret = g_task_propagate_boolean (G_TASK (result), error);
+ ret = ide_task_propagate_boolean (IDE_TASK (result), error);
IDE_RETURN (ret);
}
diff --git a/src/plugins/ctags/ide-ctags-index.c b/src/plugins/ctags/ide-ctags-index.c
index 929a2508d..8fb857afd 100644
--- a/src/plugins/ctags/ide-ctags-index.c
+++ b/src/plugins/ctags/ide-ctags-index.c
@@ -185,7 +185,7 @@ ide_ctags_index_parse_line (gchar *line,
}
static void
-ide_ctags_index_build_index (GTask *task,
+ide_ctags_index_build_index (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
@@ -201,7 +201,7 @@ ide_ctags_index_build_index (GTask *task,
IDE_ENTRY;
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_CTAGS_INDEX (self));
g_assert (G_IS_FILE (self->file));
@@ -246,7 +246,7 @@ ide_ctags_index_build_index (GTask *task,
DZL_COUNTER_ADD (index_entries, (gint64)index->len);
DZL_COUNTER_ADD (heap_size, (gint64)length);
- g_task_return_boolean (task, TRUE);
+ ide_task_return_boolean (task, TRUE);
IDE_EXIT;
@@ -255,12 +255,12 @@ failure:
g_clear_pointer (&index, g_array_unref);
if (error != NULL)
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
else
- g_task_return_new_error (task,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "Failed to parse ctags file.");
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Failed to parse ctags file.");
IDE_EXIT;
}
@@ -430,23 +430,23 @@ ide_ctags_index_init_async (GAsyncInitable *initable,
gpointer user_data)
{
IdeCtagsIndex *self = (IdeCtagsIndex *)initable;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
g_assert (IDE_IS_CTAGS_INDEX (self));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
- task = g_task_new (self, cancellable, callback, user_data);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_priority (task, G_PRIORITY_LOW + 100);
+ ide_task_set_source_tag (task, ide_ctags_index_init_async);
+ ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
if (self->file == NULL)
- {
- g_task_return_new_error (task,
+ ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"You must set IdeCtagsIndex:file before async initialization");
- return;
- }
-
- ide_thread_pool_push_task (IDE_THREAD_POOL_INDEXER, task, ide_ctags_index_build_index);
+ else
+ ide_task_run_in_thread (task, ide_ctags_index_build_index);
}
static gboolean
@@ -455,9 +455,9 @@ ide_ctags_index_init_finish (GAsyncInitable *initable,
GError **error)
{
g_assert (IDE_IS_CTAGS_INDEX (initable));
- g_assert (G_IS_TASK (result));
+ g_assert (IDE_IS_TASK (result));
- return g_task_propagate_boolean (G_TASK (result), error);
+ return ide_task_propagate_boolean (IDE_TASK (result), error);
}
static void
diff --git a/src/plugins/ctags/ide-ctags-symbol-node.c b/src/plugins/ctags/ide-ctags-symbol-node.c
index 1d2eddfbb..5426e05eb 100644
--- a/src/plugins/ctags/ide-ctags-symbol-node.c
+++ b/src/plugins/ctags/ide-ctags-symbol-node.c
@@ -38,20 +38,20 @@ ide_ctags_symbol_node_get_location_cb (GObject *object,
{
IdeCtagsSymbolResolver *resolver = (IdeCtagsSymbolResolver *)object;
g_autoptr(IdeSourceLocation) location = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_assert (IDE_IS_CTAGS_SYMBOL_RESOLVER (resolver));
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
location = ide_ctags_symbol_resolver_get_location_finish (resolver, result, &error);
if (location == NULL)
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
else
- g_task_return_pointer (task,
- g_steal_pointer (&location),
- (GDestroyNotify)ide_source_location_unref);
+ ide_task_return_pointer (task,
+ g_steal_pointer (&location),
+ (GDestroyNotify)ide_source_location_unref);
}
static void
@@ -61,12 +61,12 @@ ide_ctags_symbol_node_get_location_async (IdeSymbolNode *node,
gpointer user_data)
{
IdeCtagsSymbolNode *self = (IdeCtagsSymbolNode *)node;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
g_return_if_fail (IDE_IS_CTAGS_SYMBOL_NODE (self));
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, ide_ctags_symbol_node_get_location_async);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_source_tag (task, ide_ctags_symbol_node_get_location_async);
ide_ctags_symbol_resolver_get_location_async (self->resolver,
self->index,
@@ -82,9 +82,9 @@ ide_ctags_symbol_node_get_location_finish (IdeSymbolNode *node,
GError **error)
{
g_return_val_if_fail (IDE_IS_CTAGS_SYMBOL_NODE (node), NULL);
- g_return_val_if_fail (G_IS_TASK (result), NULL);
+ g_return_val_if_fail (IDE_IS_TASK (result), NULL);
- return g_task_propagate_pointer (G_TASK (result), error);
+ return ide_task_propagate_pointer (IDE_TASK (result), error);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]