[sysprof/wip/chergert/sysprof-3] helpers: add sync helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/chergert/sysprof-3] helpers: add sync helper
- Date: Fri, 10 May 2019 00:31:04 +0000 (UTC)
commit 82685e7e9e8b50065c4fa3470fe9faf8c5206728
Author: Christian Hergert <chergert redhat com>
Date: Thu May 9 17:29:39 2019 -0700
helpers: add sync helper
src/libsysprof/sysprof-helpers.c | 33 +++++++++++++++++++++++++++++++--
src/libsysprof/sysprof-helpers.h | 5 +++++
2 files changed, 36 insertions(+), 2 deletions(-)
---
diff --git a/src/libsysprof/sysprof-helpers.c b/src/libsysprof/sysprof-helpers.c
index 0b1a10b..2b7ca59 100644
--- a/src/libsysprof/sysprof-helpers.c
+++ b/src/libsysprof/sysprof-helpers.c
@@ -158,6 +158,35 @@ sysprof_helpers_list_processes_cb (IpcService *service,
"Failed to list processes");
}
+gboolean
+sysprof_helpers_list_processes (SysprofHelpers *self,
+ GCancellable *cancellable,
+ gint32 **processes,
+ gsize *n_processes,
+ GError **error)
+{
+ g_autoptr(GVariant) fixed_ar = NULL;
+
+ g_return_val_if_fail (SYSPROF_IS_HELPERS (self), FALSE);
+ g_return_val_if_fail (processes != NULL, FALSE);
+ g_return_val_if_fail (n_processes != NULL, FALSE);
+
+ if (ipc_service_call_list_processes_sync (self->proxy, &fixed_ar, cancellable, NULL))
+ {
+ const gint32 *data;
+ gsize len;
+
+ data = g_variant_get_fixed_array (fixed_ar, &len, sizeof (gint32));
+ *processes = g_memdup (data, len * sizeof (gint32));
+ *n_processes = len;
+
+ return TRUE;
+ }
+
+ helpers_list_processes (processes, n_processes);
+ return TRUE;
+}
+
void
sysprof_helpers_list_processes_async (SysprofHelpers *self,
GCancellable *cancellable,
@@ -280,7 +309,7 @@ sysprof_helpers_get_proc_file_async (SysprofHelpers *self,
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, sysprof_helpers_list_processes_async);
+ g_task_set_source_tag (task, sysprof_helpers_get_proc_file_async);
g_task_set_task_data (task, g_strdup (path), g_free);
if (!fail_if_no_proxy (self, task))
@@ -417,7 +446,7 @@ sysprof_helpers_perf_event_open_async (SysprofHelpers *self,
g_return_if_fail (group_fd >= -1);
task = g_task_new (self, cancellable, callback, user_data);
- g_task_set_source_tag (task, sysprof_helpers_list_processes_async);
+ g_task_set_source_tag (task, sysprof_helpers_perf_event_open_async);
if (!fail_if_no_proxy (self, task))
{
diff --git a/src/libsysprof/sysprof-helpers.h b/src/libsysprof/sysprof-helpers.h
index daa4aa0..f8aeed2 100644
--- a/src/libsysprof/sysprof-helpers.h
+++ b/src/libsysprof/sysprof-helpers.h
@@ -33,6 +33,11 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (SysprofHelpers, sysprof_helpers, SYSPROF, HELPERS, GObject)
SysprofHelpers *sysprof_helpers_get_default (void);
+gboolean sysprof_helpers_list_processes (SysprofHelpers *self,
+ GCancellable *cancellable,
+ gint32 **processes,
+ gsize *n_processes,
+ GError **error);
void sysprof_helpers_list_processes_async (SysprofHelpers *self,
GCancellable *cancellable,
GAsyncReadyCallback callback,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]