From b08bd04abe0d031fb7baa4ad2147ebe07c4a7521 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 25 Jun 2020 23:36:08 +0100 Subject: gtask: Improve task names used internally within GLib And improve them externally, where not otherwise set, by setting them from the function name passed to `g_task_set_source_tag()`, if called by third party code. This should make profiling and debug output from GLib more useful. Signed-off-by: Philip Withnall --- gio/gtask.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gio/gtask.h') diff --git a/gio/gtask.h b/gio/gtask.h index 73a31e157..08ed7be72 100644 --- a/gio/gtask.h +++ b/gio/gtask.h @@ -78,6 +78,14 @@ GLIB_AVAILABLE_IN_2_60 void g_task_set_name (GTask *task, const gchar *name); +/* Macro wrapper to set the task name when setting the source tag. */ +#define g_task_set_source_tag(task, tag) G_STMT_START { \ + GTask *_task = (task); \ + (g_task_set_source_tag) (_task, tag); \ + if (g_task_get_name (_task) == NULL) \ + g_task_set_name (_task, G_STRINGIFY (tag)); \ +} G_STMT_END + GLIB_AVAILABLE_IN_2_36 gpointer g_task_get_source_object (GTask *task); GLIB_AVAILABLE_IN_2_36 -- cgit v1.2.3-70-g09d2