mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-10 15:10:53 +00:00
libsysprof: process local task parsing on a thread
This commit is contained in:
@ -107,6 +107,37 @@ fail_if_no_proxy (SysprofHelpers *self,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_helpers_list_processes_local_cb (GObject *object,
|
||||||
|
GAsyncResult *result,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_autoptr(GTask) task = user_data;
|
||||||
|
g_autoptr(GError) error = NULL;
|
||||||
|
g_autofree gint32 *processes = NULL;
|
||||||
|
gsize n_processes = 0;
|
||||||
|
|
||||||
|
g_assert (G_IS_ASYNC_RESULT (result));
|
||||||
|
g_assert (G_IS_TASK (task));
|
||||||
|
|
||||||
|
if (helpers_list_processes_finish (result, &processes, &n_processes, &error))
|
||||||
|
{
|
||||||
|
g_autoptr(GVariant) ret = NULL;
|
||||||
|
|
||||||
|
ret = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32,
|
||||||
|
processes,
|
||||||
|
n_processes,
|
||||||
|
sizeof (gint32));
|
||||||
|
g_task_return_pointer (task,
|
||||||
|
g_variant_take_ref (g_steal_pointer (&ret)),
|
||||||
|
(GDestroyNotify) g_variant_unref);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_task_return_error (task, g_steal_pointer (&error));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sysprof_helpers_list_processes_cb (IpcService *service,
|
sysprof_helpers_list_processes_cb (IpcService *service,
|
||||||
GAsyncResult *result,
|
GAsyncResult *result,
|
||||||
@ -121,24 +152,11 @@ sysprof_helpers_list_processes_cb (IpcService *service,
|
|||||||
g_assert (G_IS_TASK (task));
|
g_assert (G_IS_TASK (task));
|
||||||
|
|
||||||
if (!ipc_service_call_list_processes_finish (service, &processes, result, &error))
|
if (!ipc_service_call_list_processes_finish (service, &processes, result, &error))
|
||||||
{
|
helpers_list_processes_async (g_task_get_cancellable (task),
|
||||||
g_autofree gint32 *out_processes = NULL;
|
sysprof_helpers_list_processes_local_cb,
|
||||||
gsize out_n_processes = 0;
|
g_object_ref (task));
|
||||||
|
|
||||||
if (helpers_list_processes (&out_processes, &out_n_processes))
|
|
||||||
processes = g_variant_new_fixed_array (G_VARIANT_TYPE_INT32,
|
|
||||||
out_processes,
|
|
||||||
out_n_processes,
|
|
||||||
sizeof (gint32));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (processes != NULL)
|
|
||||||
g_task_return_pointer (task, g_steal_pointer (&processes), (GDestroyNotify) g_variant_unref);
|
|
||||||
else
|
else
|
||||||
g_task_return_new_error (task,
|
g_task_return_pointer (task, g_steal_pointer (&processes), (GDestroyNotify) g_variant_unref);
|
||||||
G_IO_ERROR,
|
|
||||||
G_IO_ERROR_NOT_SUPPORTED,
|
|
||||||
"Failed to list processes");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|||||||
Reference in New Issue
Block a user