[gnome-builder] clang: port various API to IdeTask
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] clang: port various API to IdeTask
- Date: Wed, 21 Mar 2018 08:05:14 +0000 (UTC)
commit ce4d1873db4af0a8d0f95b0c6962155a2514a275
Author: Christian Hergert <chergert redhat com>
Date: Wed Mar 21 01:04:26 2018 -0700
clang: port various API to IdeTask
The service still needs DzlTaskCache, but we can use IdeTask
for lots of other stuff that will interact with widgets/etc.
src/plugins/clang/ide-clang-code-indexer.c | 81 ++++++++++----------
src/plugins/clang/ide-clang-diagnostic-provider.c | 28 +++----
src/plugins/clang/ide-clang-symbol-node.c | 18 ++---
src/plugins/clang/ide-clang-symbol-resolver.c | 92 +++++++++++------------
src/plugins/clang/ide-clang-translation-unit.c | 44 ++++++-----
5 files changed, 130 insertions(+), 133 deletions(-)
---
diff --git a/src/plugins/clang/ide-clang-code-indexer.c b/src/plugins/clang/ide-clang-code-indexer.c
index 84e35ca8e..7377c2572 100644
--- a/src/plugins/clang/ide-clang-code-indexer.c
+++ b/src/plugins/clang/ide-clang-code-indexer.c
@@ -43,7 +43,7 @@ build_request_free (gpointer data)
}
static void
-ide_clang_code_indexer_index_file_worker (GTask *task,
+ide_clang_code_indexer_index_file_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
@@ -54,7 +54,7 @@ ide_clang_code_indexer_index_file_worker (GTask *task,
g_autofree gchar *path = NULL;
enum CXErrorCode code;
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
g_assert (IDE_IS_CLANG_CODE_INDEXER (source_object));
g_assert (br != NULL);
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
@@ -78,17 +78,17 @@ ide_clang_code_indexer_index_file_worker (GTask *task,
&unit);
if (code != CXError_Success)
- g_task_return_new_error (task,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "Failed to index \"%s\"",
- path);
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_FAILED,
+ "Failed to index \"%s\"",
+ path);
else
- g_task_return_pointer (task,
- ide_clang_code_index_entries_new (g_steal_pointer (&index),
- g_steal_pointer (&unit),
- path),
- g_object_unref);
+ ide_task_return_pointer (task,
+ ide_clang_code_index_entries_new (g_steal_pointer (&index),
+ g_steal_pointer (&unit),
+ path),
+ g_object_unref);
}
static void
@@ -100,34 +100,33 @@ ide_clang_code_indexer_index_file_async (IdeCodeIndexer *indexer,
gpointer user_data)
{
IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
BuildRequest *br;
g_assert (IDE_IS_CLANG_CODE_INDEXER (self));
g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, ide_clang_code_indexer_index_file_async);
- g_task_set_priority (task, G_PRIORITY_LOW);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_source_tag (task, ide_clang_code_indexer_index_file_async);
+ ide_task_set_priority (task, G_PRIORITY_LOW);
+ ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
if (!g_file_is_native (file))
{
- g_task_return_new_error (task,
- G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- "Only native files are supported");
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ "Only native files are supported");
return;
}
br = g_slice_new0 (BuildRequest);
br->build_flags = g_strdupv ((gchar **)args);
br->file = g_object_ref (file);
- g_task_set_task_data (task, br, build_request_free);
+ ide_task_set_task_data (task, br, build_request_free);
- ide_thread_pool_push_task (IDE_THREAD_POOL_INDEXER,
- task,
- ide_clang_code_indexer_index_file_worker);
+ ide_task_run_in_thread (task, ide_clang_code_indexer_index_file_worker);
}
static IdeCodeIndexEntries *
@@ -136,9 +135,9 @@ ide_clang_code_indexer_index_file_finish (IdeCodeIndexer *indexer,
GError **error)
{
g_assert (IDE_IS_CLANG_CODE_INDEXER (indexer));
- g_assert (G_IS_TASK (result));
+ g_assert (IDE_IS_TASK (result));
- return g_task_propagate_pointer (G_TASK (result), error);
+ return ide_task_propagate_pointer (IDE_TASK (result), error);
}
static void
@@ -148,28 +147,28 @@ ide_clang_code_indexer_generate_key_cb (GObject *object,
{
IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) unit = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
g_autofree gchar *key = NULL;
IdeSourceLocation *location;
g_assert (IDE_IS_CLANG_SERVICE (service));
g_assert (G_IS_ASYNC_RESULT (result));
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
if (!(unit = ide_clang_service_get_translation_unit_finish (service, result, &error)))
{
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
return;
}
- location = g_task_get_task_data (task);
+ location = ide_task_get_task_data (task);
g_assert (location != NULL);
if (!(key = ide_clang_translation_unit_generate_key (unit, location)))
- g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Key not found");
+ ide_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "Key not found");
else
- g_task_return_pointer (task, g_steal_pointer (&key), g_free);
+ ide_task_return_pointer (task, g_steal_pointer (&key), g_free);
}
static void
@@ -180,7 +179,7 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer,
gpointer user_data)
{
IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
IdeClangService *service;
IdeContext *context;
@@ -193,13 +192,13 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer,
* can be referenced across compilation units.
*/
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, ide_clang_code_indexer_generate_key_async);
- g_task_set_priority (task, G_PRIORITY_LOW);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_source_tag (task, ide_clang_code_indexer_generate_key_async);
+ ide_task_set_priority (task, G_PRIORITY_LOW);
- g_task_set_task_data (task,
- ide_source_location_ref (location),
- (GDestroyNotify)ide_source_location_unref);
+ ide_task_set_task_data (task,
+ ide_source_location_ref (location),
+ (GDestroyNotify)ide_source_location_unref);
context = ide_object_get_context (IDE_OBJECT (self));
g_assert (IDE_IS_CONTEXT (context));
@@ -221,9 +220,9 @@ ide_clang_code_indexer_generate_key_finish (IdeCodeIndexer *self,
GError **error)
{
g_assert (IDE_IS_CODE_INDEXER (self));
- g_assert (G_IS_TASK (result));
+ g_assert (IDE_IS_TASK (result));
- return g_task_propagate_pointer (G_TASK (result), error);
+ return ide_task_propagate_pointer (IDE_TASK (result), error);
}
static void
diff --git a/src/plugins/clang/ide-clang-diagnostic-provider.c
b/src/plugins/clang/ide-clang-diagnostic-provider.c
index ce8dc149d..9487a6b99 100644
--- a/src/plugins/clang/ide-clang-diagnostic-provider.c
+++ b/src/plugins/clang/ide-clang-diagnostic-provider.c
@@ -50,7 +50,7 @@ get_translation_unit_cb (GObject *object,
{
IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) tu = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
IdeDiagnostics *diagnostics;
IdeFile *target;
@@ -60,11 +60,11 @@ get_translation_unit_cb (GObject *object,
if (!tu)
{
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
return;
}
- target = g_task_get_task_data (task);
+ target = ide_task_get_task_data (task);
g_assert (IDE_IS_FILE (target));
gfile = ide_file_get_file (target);
@@ -72,9 +72,9 @@ get_translation_unit_cb (GObject *object,
diagnostics = ide_clang_translation_unit_get_diagnostics_for_file (tu, gfile);
- g_task_return_pointer (task,
- ide_diagnostics_ref (diagnostics),
- (GDestroyNotify)ide_diagnostics_unref);
+ ide_task_return_pointer (task,
+ ide_diagnostics_ref (diagnostics),
+ (GDestroyNotify)ide_diagnostics_unref);
}
static gboolean
@@ -99,7 +99,7 @@ ide_clang_diagnostic_provider_diagnose__file_find_other_cb (GObject *object
{
IdeFile *file = (IdeFile *)object;
g_autoptr(IdeFile) other = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
IdeClangService *service;
IdeContext *context;
@@ -116,7 +116,7 @@ ide_clang_diagnostic_provider_diagnose__file_find_other_cb (GObject *object
ide_clang_service_get_translation_unit_async (service,
file,
0,
- g_task_get_cancellable (task),
+ ide_task_get_cancellable (task),
get_translation_unit_cb,
g_object_ref (task));
}
@@ -130,12 +130,12 @@ ide_clang_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
gpointer user_data)
{
IdeClangDiagnosticProvider *self = (IdeClangDiagnosticProvider *)provider;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
g_return_if_fail (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (self));
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_task_data (task, g_object_ref (file), g_object_unref);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
if (is_header (file))
{
@@ -166,12 +166,12 @@ ide_clang_diagnostic_provider_diagnose_finish (IdeDiagnosticProvider *provider,
GAsyncResult *result,
GError **error)
{
- GTask *task = (GTask *)result;
+ IdeTask *task = (IdeTask *)result;
g_return_val_if_fail (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (provider), NULL);
- g_return_val_if_fail (G_IS_TASK (task), NULL);
+ g_return_val_if_fail (IDE_IS_TASK (task), NULL);
- return g_task_propagate_pointer (task, error);
+ return ide_task_propagate_pointer (task, error);
}
static void
diff --git a/src/plugins/clang/ide-clang-symbol-node.c b/src/plugins/clang/ide-clang-symbol-node.c
index 962a93361..413d69e97 100644
--- a/src/plugins/clang/ide-clang-symbol-node.c
+++ b/src/plugins/clang/ide-clang-symbol-node.c
@@ -174,7 +174,7 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
IdeClangSymbolNode *self = (IdeClangSymbolNode *)symbol_node;
g_autoptr(IdeFile) ifile = NULL;
g_autoptr(GFile) gfile = NULL;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
g_auto(CXString) cxfilename = {0};
IdeContext *context;
const gchar *filename;
@@ -185,9 +185,9 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
g_return_if_fail (IDE_IS_CLANG_SYMBOL_NODE (self));
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, ide_clang_symbol_node_get_location_async);
- g_task_set_priority (task, G_PRIORITY_LOW);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_source_tag (task, ide_clang_symbol_node_get_location_async);
+ ide_task_set_priority (task, G_PRIORITY_LOW);
cxloc = clang_getCursorLocation (self->cursor);
clang_getFileLocation (cxloc, &file, &line, &line_offset, NULL);
@@ -202,9 +202,9 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
gfile = g_file_new_for_path (filename);
ifile = ide_file_new (context, gfile);
- g_task_return_pointer (task,
- ide_source_location_new (ifile, line-1, line_offset-1, 0),
- (GDestroyNotify)ide_source_location_unref);
+ ide_task_return_pointer (task,
+ ide_source_location_new (ifile, line-1, line_offset-1, 0),
+ (GDestroyNotify)ide_source_location_unref);
}
static IdeSourceLocation *
@@ -213,9 +213,9 @@ ide_clang_symbol_node_get_location_finish (IdeSymbolNode *symbol_node,
GError **error)
{
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_NODE (symbol_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
diff --git a/src/plugins/clang/ide-clang-symbol-resolver.c b/src/plugins/clang/ide-clang-symbol-resolver.c
index 0636f2783..5cbf50a50 100644
--- a/src/plugins/clang/ide-clang-symbol-resolver.c
+++ b/src/plugins/clang/ide-clang-symbol-resolver.c
@@ -39,21 +39,21 @@ ide_clang_symbol_resolver_lookup_symbol_cb (GObject *object,
{
IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) unit = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
g_autoptr(IdeSymbol) symbol = NULL;
g_autoptr(GError) error = NULL;
IdeSourceLocation *location;
g_assert (IDE_IS_CLANG_SERVICE (service));
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
- location = g_task_get_task_data (task);
+ location = ide_task_get_task_data (task);
unit = ide_clang_service_get_translation_unit_finish (service, result, &error);
if (unit == NULL)
{
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
return;
}
@@ -61,11 +61,11 @@ ide_clang_symbol_resolver_lookup_symbol_cb (GObject *object,
if (symbol == NULL)
{
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
return;
}
- g_task_return_pointer (task, g_steal_pointer (&symbol), (GDestroyNotify)ide_symbol_unref);
+ ide_task_return_pointer (task, g_steal_pointer (&symbol), (GDestroyNotify)ide_symbol_unref);
}
static void
@@ -79,7 +79,7 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver,
IdeClangService *service = NULL;
IdeContext *context;
IdeFile *file;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
IDE_ENTRY;
@@ -90,10 +90,10 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver,
service = ide_context_get_service_typed (context, IDE_TYPE_CLANG_SERVICE);
file = ide_source_location_get_file (location);
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_priority (task, G_PRIORITY_LOW);
- g_task_set_task_data (task, ide_source_location_ref (location),
- (GDestroyNotify)ide_source_location_unref);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_priority (task, G_PRIORITY_LOW);
+ ide_task_set_task_data (task, ide_source_location_ref (location),
+ (GDestroyNotify)ide_source_location_unref);
ide_clang_service_get_translation_unit_async (service,
file,
@@ -111,14 +111,14 @@ ide_clang_symbol_resolver_lookup_symbol_finish (IdeSymbolResolver *resolver,
GError **error)
{
IdeSymbol *ret;
- GTask *task = (GTask *)result;
+ IdeTask *task = (IdeTask *)result;
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_RESOLVER (resolver), NULL);
- g_return_val_if_fail (G_IS_TASK (task), NULL);
+ g_return_val_if_fail (IDE_IS_TASK (task), NULL);
- ret = g_task_propagate_pointer (task, error);
+ ret = ide_task_propagate_pointer (task, error);
IDE_RETURN (ret);
}
@@ -130,15 +130,15 @@ ide_clang_symbol_resolver_get_symbol_tree_cb2 (GObject *object,
{
IdeClangTranslationUnit *unit = (IdeClangTranslationUnit *)object;
g_autoptr(IdeSymbolTree) ret = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
ret = ide_clang_translation_unit_get_symbol_tree_finish (unit, result, &error);
if (ret == 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 (&ret), g_object_unref);
+ ide_task_return_pointer (task, g_steal_pointer (&ret), g_object_unref);
}
static void
@@ -148,29 +148,29 @@ ide_clang_symbol_resolver_get_symbol_tree_cb (GObject *object,
{
IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) unit = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
GFile *file;
IDE_ENTRY;
g_assert (IDE_IS_CLANG_SERVICE (service));
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
unit = ide_clang_service_get_translation_unit_finish (service, result, &error);
if (unit == NULL)
{
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT;
}
- file = g_task_get_task_data (task);
+ file = ide_task_get_task_data (task);
g_assert (G_IS_FILE (file));
ide_clang_translation_unit_get_symbol_tree_async (unit,
file,
- g_task_get_cancellable (task),
+ ide_task_get_cancellable (task),
ide_clang_symbol_resolver_get_symbol_tree_cb2,
g_object_ref (task));
@@ -186,7 +186,7 @@ ide_clang_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver *resolver,
gpointer user_data)
{
IdeClangSymbolResolver *self = (IdeClangSymbolResolver *)resolver;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
g_autoptr(IdeFile) ifile = NULL;
IdeClangService *service;
IdeContext *context;
@@ -200,9 +200,9 @@ ide_clang_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver *resolver,
context = ide_object_get_context (IDE_OBJECT (self));
service = ide_context_get_service_typed (context, IDE_TYPE_CLANG_SERVICE);
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_priority (task, G_PRIORITY_LOW);
- g_task_set_task_data (task, g_object_ref (file), g_object_unref);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_priority (task, G_PRIORITY_LOW);
+ ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
ifile = ide_file_new (context, file);
@@ -222,14 +222,14 @@ ide_clang_symbol_resolver_get_symbol_tree_finish (IdeSymbolResolver *resolver,
GError **error)
{
IdeSymbolTree *ret;
- GTask *task = (GTask *)result;
+ IdeTask *task = (IdeTask *)result;
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_RESOLVER (resolver), NULL);
- g_return_val_if_fail (G_IS_TASK (task), NULL);
+ g_return_val_if_fail (IDE_IS_TASK (task), NULL);
- ret = g_task_propagate_pointer (task, error);
+ ret = ide_task_propagate_pointer (task, error);
IDE_RETURN (ret);
}
@@ -241,32 +241,32 @@ ide_clang_symbol_resolver_find_scope_cb (GObject *object,
{
IdeClangService *service = (IdeClangService *)object;
g_autoptr(IdeClangTranslationUnit) unit = NULL;
- g_autoptr(GTask) task = user_data;
+ g_autoptr(IdeTask) task = user_data;
g_autoptr(IdeSymbol) symbol = NULL;
g_autoptr(GError) error = NULL;
IdeSourceLocation *location;
g_assert (IDE_IS_CLANG_SERVICE (service));
g_assert (G_IS_ASYNC_RESULT (result));
- g_assert (G_IS_TASK (task));
+ g_assert (IDE_IS_TASK (task));
unit = ide_clang_service_get_translation_unit_finish (service, result, &error);
if (unit == NULL)
{
- g_task_return_error (task, g_steal_pointer (&error));
+ ide_task_return_error (task, g_steal_pointer (&error));
return;
}
- location = g_task_get_task_data (task);
+ location = ide_task_get_task_data (task);
symbol = ide_clang_translation_unit_find_nearest_scope (unit, location, &error);
if (symbol == 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 (&symbol),
- (GDestroyNotify) ide_symbol_unref);
+ ide_task_return_pointer (task,
+ g_steal_pointer (&symbol),
+ (GDestroyNotify) ide_symbol_unref);
}
static void
@@ -277,7 +277,7 @@ ide_clang_symbol_resolver_find_nearest_scope_async (IdeSymbolResolver *symbol_
gpointer user_data)
{
IdeClangSymbolResolver *self = (IdeClangSymbolResolver *)symbol_resolver;
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
IdeClangService *service;
IdeContext *context;
IdeFile *file;
@@ -287,12 +287,12 @@ ide_clang_symbol_resolver_find_nearest_scope_async (IdeSymbolResolver *symbol_
g_return_if_fail (IDE_IS_CLANG_SYMBOL_RESOLVER (self));
g_return_if_fail (location != NULL);
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_priority (task, G_PRIORITY_LOW);
- g_task_set_source_tag (task, ide_clang_symbol_resolver_find_nearest_scope_async);
- g_task_set_task_data (task,
- ide_source_location_ref (location),
- (GDestroyNotify) ide_source_location_unref);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_priority (task, G_PRIORITY_LOW);
+ ide_task_set_source_tag (task, ide_clang_symbol_resolver_find_nearest_scope_async);
+ ide_task_set_task_data (task,
+ ide_source_location_ref (location),
+ (GDestroyNotify) ide_source_location_unref);
context = ide_object_get_context (IDE_OBJECT (self));
service = ide_context_get_service_typed (context, IDE_TYPE_CLANG_SERVICE);
@@ -318,9 +318,9 @@ ide_clang_symbol_resolver_find_nearest_scope_finish (IdeSymbolResolver *resolve
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_RESOLVER (resolver), NULL);
- g_return_val_if_fail (G_IS_TASK (result), NULL);
+ g_return_val_if_fail (IDE_IS_TASK (result), NULL);
- ret = g_task_propagate_pointer (G_TASK (result), error);
+ ret = ide_task_propagate_pointer (IDE_TASK (result), error);
IDE_RETURN (ret);
}
diff --git a/src/plugins/clang/ide-clang-translation-unit.c b/src/plugins/clang/ide-clang-translation-unit.c
index ecef20772..dfe65202e 100644
--- a/src/plugins/clang/ide-clang-translation-unit.c
+++ b/src/plugins/clang/ide-clang-translation-unit.c
@@ -585,7 +585,7 @@ ide_clang_translation_unit_init (IdeClangTranslationUnit *self)
}
static void
-ide_clang_translation_unit_code_complete_worker (GTask *task,
+ide_clang_translation_unit_code_complete_worker (IdeTask *task,
gpointer source_object,
gpointer task_data,
GCancellable *cancellable)
@@ -614,10 +614,10 @@ ide_clang_translation_unit_code_complete_worker (GTask *task,
if (!state->path)
{
/* implausable to reach here, anyway */
- g_task_return_new_error (task,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_FILENAME,
- _("clang_codeCompleteAt() only works on local files"));
+ ide_task_return_new_error (task,
+ G_IO_ERROR,
+ G_IO_ERROR_INVALID_FILENAME,
+ _("clang_codeCompleteAt() only works on local files"));
return;
}
@@ -667,7 +667,7 @@ ide_clang_translation_unit_code_complete_worker (GTask *task,
for (i = 0; i < results->NumResults; i++)
g_ptr_array_add (ar, ide_clang_completion_item_new (refptr, i));
- g_task_return_pointer (task, ar, (GDestroyNotify)g_ptr_array_unref);
+ ide_task_return_pointer (task, ar, (GDestroyNotify)g_ptr_array_unref);
/* cleanup malloc'd state */
for (i = 0; i < j; i++)
@@ -684,7 +684,7 @@ ide_clang_translation_unit_code_complete_async (IdeClangTranslationUnit *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
CodeCompleteState *state;
IdeContext *context;
IdeUnsavedFiles *unsaved_files;
@@ -699,7 +699,7 @@ ide_clang_translation_unit_code_complete_async (IdeClangTranslationUnit *self,
context = ide_object_get_context (IDE_OBJECT (self));
unsaved_files = ide_context_get_unsaved_files (context);
- task = g_task_new (self, cancellable, callback, user_data);
+ task = ide_task_new (self, cancellable, callback, user_data);
state = g_new0 (CodeCompleteState, 1);
state->path = g_file_get_path (file);
@@ -712,11 +712,9 @@ ide_clang_translation_unit_code_complete_async (IdeClangTranslationUnit *self,
* that only one thread is dealing with this at a time.
*/
- g_task_set_task_data (task, state, code_complete_state_free);
-
- ide_thread_pool_push_task (IDE_THREAD_POOL_COMPILER,
- task,
- ide_clang_translation_unit_code_complete_worker);
+ ide_task_set_task_data (task, state, code_complete_state_free);
+ ide_task_set_kind (task, IDE_TASK_KIND_COMPILER);
+ ide_task_run_in_thread (task, ide_clang_translation_unit_code_complete_worker);
IDE_EXIT;
}
@@ -737,15 +735,15 @@ ide_clang_translation_unit_code_complete_finish (IdeClangTranslationUnit *self,
GAsyncResult *result,
GError **error)
{
- GTask *task = (GTask *)result;
+ IdeTask *task = (IdeTask *)result;
GPtrArray *ret;
IDE_ENTRY;
g_return_val_if_fail (IDE_IS_CLANG_TRANSLATION_UNIT (self), NULL);
- g_return_val_if_fail (G_IS_TASK (task), NULL);
+ g_return_val_if_fail (IDE_IS_TASK (task), NULL);
- ret = g_task_propagate_pointer (task, error);
+ ret = ide_task_propagate_pointer (task, error);
IDE_RETURN (ret);
}
@@ -1059,7 +1057,7 @@ ide_clang_translation_unit_get_symbol_tree_async (IdeClangTranslationUnit *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- g_autoptr(GTask) task = NULL;
+ g_autoptr(IdeTask) task = NULL;
g_autoptr(IdeSymbolTree) symbol_tree = NULL;
IdeContext *context;
@@ -1067,9 +1065,9 @@ ide_clang_translation_unit_get_symbol_tree_async (IdeClangTranslationUnit *self,
g_return_if_fail (G_IS_FILE (file));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
- task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, ide_clang_translation_unit_get_symbol_tree_async);
- g_task_set_priority (task, G_PRIORITY_LOW);
+ task = ide_task_new (self, cancellable, callback, user_data);
+ ide_task_set_source_tag (task, ide_clang_translation_unit_get_symbol_tree_async);
+ ide_task_set_priority (task, G_PRIORITY_LOW);
context = ide_object_get_context (IDE_OBJECT (self));
symbol_tree = g_object_new (IDE_TYPE_CLANG_SYMBOL_TREE,
@@ -1077,7 +1075,7 @@ ide_clang_translation_unit_get_symbol_tree_async (IdeClangTranslationUnit *self,
"native", self->native,
"file", file,
NULL);
- g_task_return_pointer (task, g_steal_pointer (&symbol_tree), g_object_unref);
+ ide_task_return_pointer (task, g_steal_pointer (&symbol_tree), g_object_unref);
}
IdeSymbolTree *
@@ -1086,9 +1084,9 @@ ide_clang_translation_unit_get_symbol_tree_finish (IdeClangTranslationUnit *sel
GError **error)
{
g_return_val_if_fail (IDE_IS_CLANG_TRANSLATION_UNIT (self), 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 gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]