Commit 7664c4b7 authored by Christian Hergert's avatar Christian Hergert
Browse files

workers: port to IdeTask

parent fe718a0e
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "workers/ide-worker-process.h" #include "workers/ide-worker-process.h"
#include "workers/ide-worker-manager.h" #include "workers/ide-worker-manager.h"
#include "threading/ide-task.h"
struct _IdeWorkerManager struct _IdeWorkerManager
{ {
...@@ -225,21 +226,21 @@ ide_worker_manager_get_worker_cb (GObject *object, ...@@ -225,21 +226,21 @@ ide_worker_manager_get_worker_cb (GObject *object,
gpointer user_data) gpointer user_data)
{ {
IdeWorkerProcess *worker_process = (IdeWorkerProcess *)object; IdeWorkerProcess *worker_process = (IdeWorkerProcess *)object;
g_autoptr(GTask) task = user_data; g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
GDBusProxy *proxy; GDBusProxy *proxy;
IDE_ENTRY; IDE_ENTRY;
g_assert (IDE_IS_WORKER_PROCESS (worker_process)); g_assert (IDE_IS_WORKER_PROCESS (worker_process));
g_assert (G_IS_TASK (task)); g_assert (IDE_IS_TASK (task));
proxy = ide_worker_process_get_proxy_finish (worker_process, result, &error); proxy = ide_worker_process_get_proxy_finish (worker_process, result, &error);
if (proxy == NULL) if (proxy == NULL)
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
else else
g_task_return_pointer (task, proxy, g_object_unref); ide_task_return_pointer (task, proxy, g_object_unref);
IDE_EXIT; IDE_EXIT;
} }
...@@ -252,13 +253,13 @@ ide_worker_manager_get_worker_async (IdeWorkerManager *self, ...@@ -252,13 +253,13 @@ ide_worker_manager_get_worker_async (IdeWorkerManager *self,
gpointer user_data) gpointer user_data)
{ {
IdeWorkerProcess *worker_process; IdeWorkerProcess *worker_process;
GTask *task; IdeTask *task;
g_return_if_fail (IDE_IS_WORKER_MANAGER (self)); g_return_if_fail (IDE_IS_WORKER_MANAGER (self));
g_return_if_fail (plugin_name != NULL); g_return_if_fail (plugin_name != NULL);
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data); task = ide_task_new (self, cancellable, callback, user_data);
worker_process = ide_worker_manager_get_worker_process (self, plugin_name); worker_process = ide_worker_manager_get_worker_process (self, plugin_name);
ide_worker_process_get_proxy_async (worker_process, ide_worker_process_get_proxy_async (worker_process,
cancellable, cancellable,
...@@ -271,12 +272,12 @@ ide_worker_manager_get_worker_finish (IdeWorkerManager *self, ...@@ -271,12 +272,12 @@ ide_worker_manager_get_worker_finish (IdeWorkerManager *self,
GAsyncResult *result, GAsyncResult *result,
GError **error) GError **error)
{ {
GTask *task = (GTask *)result; IdeTask *task = (IdeTask *)result;
g_return_val_if_fail (IDE_IS_WORKER_MANAGER (self), NULL); g_return_val_if_fail (IDE_IS_WORKER_MANAGER (self), 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);
} }
IdeWorkerManager * IdeWorkerManager *
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "logging/ide-log.h" #include "logging/ide-log.h"
#include "workers/ide-worker-process.h" #include "workers/ide-worker-process.h"
#include "workers/ide-worker.h" #include "workers/ide-worker.h"
#include "threading/ide-task.h"
struct _IdeWorkerProcess struct _IdeWorkerProcess
{ {
...@@ -363,7 +364,7 @@ ide_worker_process_matches_credentials (IdeWorkerProcess *self, ...@@ -363,7 +364,7 @@ ide_worker_process_matches_credentials (IdeWorkerProcess *self,
static void static void
ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self, ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self,
GTask *task) IdeTask *task)
{ {
GDBusProxy *proxy; GDBusProxy *proxy;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
...@@ -371,14 +372,14 @@ ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self, ...@@ -371,14 +372,14 @@ ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self,
IDE_ENTRY; IDE_ENTRY;
g_assert (IDE_IS_WORKER_PROCESS (self)); g_assert (IDE_IS_WORKER_PROCESS (self));
g_assert (G_IS_TASK (task)); g_assert (IDE_IS_TASK (task));
if (self->worker == NULL) if (self->worker == NULL)
{ {
g_task_return_new_error (task, ide_task_return_new_error (task,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_PROXY_FAILED, G_IO_ERROR_PROXY_FAILED,
"Failed to create IdeWorker instance."); "Failed to create IdeWorker instance.");
IDE_EXIT; IDE_EXIT;
} }
...@@ -390,11 +391,11 @@ ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self, ...@@ -390,11 +391,11 @@ ide_worker_process_create_proxy_for_task (IdeWorkerProcess *self,
error = g_error_new_literal (G_IO_ERROR, error = g_error_new_literal (G_IO_ERROR,
G_IO_ERROR_PROXY_FAILED, G_IO_ERROR_PROXY_FAILED,
"IdeWorker returned NULL and did not set an error."); "IdeWorker returned NULL and did not set an error.");
g_task_return_error (task, g_steal_pointer (&error)); ide_task_return_error (task, g_steal_pointer (&error));
IDE_EXIT; IDE_EXIT;
} }
g_task_return_pointer (task, proxy, g_object_unref); ide_task_return_pointer (task, proxy, g_object_unref);
IDE_EXIT; IDE_EXIT;
} }
...@@ -418,7 +419,7 @@ ide_worker_process_set_connection (IdeWorkerProcess *self, ...@@ -418,7 +419,7 @@ ide_worker_process_set_connection (IdeWorkerProcess *self,
for (i = 0; i < ar->len; i++) for (i = 0; i < ar->len; i++)
{ {
GTask *task = g_ptr_array_index (ar, i); IdeTask *task = g_ptr_array_index (ar, i);
ide_worker_process_create_proxy_for_task (self, task); ide_worker_process_create_proxy_for_task (self, task);
} }
} }
...@@ -431,14 +432,14 @@ ide_worker_process_get_proxy_async (IdeWorkerProcess *self, ...@@ -431,14 +432,14 @@ ide_worker_process_get_proxy_async (IdeWorkerProcess *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
g_autoptr(GTask) task = NULL; g_autoptr(IdeTask) task = NULL;
IDE_ENTRY; IDE_ENTRY;
g_return_if_fail (IDE_IS_WORKER_PROCESS (self)); g_return_if_fail (IDE_IS_WORKER_PROCESS (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data); task = ide_task_new (self, cancellable, callback, user_data);
if (self->connection != NULL) if (self->connection != NULL)
{ {
...@@ -459,15 +460,15 @@ ide_worker_process_get_proxy_finish (IdeWorkerProcess *self, ...@@ -459,15 +460,15 @@ ide_worker_process_get_proxy_finish (IdeWorkerProcess *self,
GAsyncResult *result, GAsyncResult *result,
GError **error) GError **error)
{ {
GTask *task = (GTask *)result; IdeTask *task = (IdeTask *)result;
GDBusProxy *ret; GDBusProxy *ret;
IDE_ENTRY; IDE_ENTRY;
g_return_val_if_fail (IDE_IS_WORKER_PROCESS (self), NULL); g_return_val_if_fail (IDE_IS_WORKER_PROCESS (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); IDE_RETURN (ret);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment