mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
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 <withnall@endlessm.com>
This commit is contained in:
parent
7cd67c935f
commit
b08bd04abe
@ -87,6 +87,7 @@
|
||||
* GTask *task;
|
||||
*
|
||||
* task = g_task_new (initable, cancellable, callback, user_data);
|
||||
* g_task_set_name (task, G_STRFUNC);
|
||||
*
|
||||
* switch (self->priv->state)
|
||||
* {
|
||||
|
@ -632,6 +632,7 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceSkeleton *interface
|
||||
|
||||
task = g_task_new (interface, NULL, NULL, NULL);
|
||||
g_task_set_source_tag (task, g_dbus_interface_method_dispatch_helper);
|
||||
g_task_set_name (task, "[gio] D-Bus interface method dispatch");
|
||||
g_task_set_task_data (task, data, (GDestroyNotify) dispatch_data_unref);
|
||||
g_task_run_in_thread (task, dispatch_in_thread_func);
|
||||
g_object_unref (task);
|
||||
|
@ -183,6 +183,7 @@ _g_socket_read_with_control_messages (GSocket *socket,
|
||||
|
||||
task = g_task_new (socket, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, _g_socket_read_with_control_messages);
|
||||
g_task_set_name (task, "[gio] D-Bus read");
|
||||
g_task_set_task_data (task, data, (GDestroyNotify) read_with_control_data_free);
|
||||
|
||||
if (g_socket_condition_check (socket, G_IO_IN))
|
||||
@ -1123,6 +1124,7 @@ write_message_async (GDBusWorker *worker,
|
||||
{
|
||||
data->task = g_task_new (NULL, NULL, callback, user_data);
|
||||
g_task_set_source_tag (data->task, write_message_async);
|
||||
g_task_set_name (data->task, "[gio] D-Bus write message");
|
||||
data->total_written = 0;
|
||||
write_message_continue_writing (data);
|
||||
}
|
||||
|
@ -1631,6 +1631,7 @@ async_initable_init_second_async (GAsyncInitable *initable,
|
||||
|
||||
task = g_task_new (proxy, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, async_initable_init_second_async);
|
||||
g_task_set_name (task, "[gio] D-Bus proxy init");
|
||||
g_task_set_priority (task, io_priority);
|
||||
|
||||
/* Check name ownership asynchronously - possibly also start the service */
|
||||
@ -1802,6 +1803,7 @@ async_initable_init_async (GAsyncInitable *initable,
|
||||
|
||||
task = g_task_new (proxy, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, async_initable_init_async);
|
||||
g_task_set_name (task, "[gio] D-Bus proxy init");
|
||||
g_task_set_priority (task, io_priority);
|
||||
|
||||
if (proxy->priv->bus_type != G_BUS_TYPE_NONE)
|
||||
@ -2649,6 +2651,7 @@ g_dbus_proxy_call_internal (GDBusProxy *proxy,
|
||||
my_callback = (GAsyncReadyCallback) reply_cb;
|
||||
task = g_task_new (proxy, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, g_dbus_proxy_call_internal);
|
||||
g_task_set_name (task, "[gio] D-Bus proxy call");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -576,6 +576,7 @@ lookup_by_name_async_real (GResolver *resolver,
|
||||
|
||||
task = g_task_new (resolver, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, lookup_by_name_async_real);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
if (addrs)
|
||||
g_task_return_pointer (task, addrs, (GDestroyNotify) g_resolver_free_addresses);
|
||||
else
|
||||
@ -595,6 +596,7 @@ lookup_by_name_async_real (GResolver *resolver,
|
||||
_("Invalid hostname"));
|
||||
task = g_task_new (resolver, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, lookup_by_name_async_real);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
@ -613,6 +615,7 @@ lookup_by_name_async_real (GResolver *resolver,
|
||||
_("%s not implemented"), "lookup_by_name_with_flags_async");
|
||||
task = g_task_new (resolver, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, lookup_by_name_async_real);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
@ -759,6 +759,7 @@ g_task_report_error (gpointer source_object,
|
||||
|
||||
task = g_task_new (source_object, NULL, callback, callback_data);
|
||||
g_task_set_source_tag (task, source_tag);
|
||||
g_task_set_name (task, G_STRFUNC);
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
}
|
||||
@ -982,8 +983,8 @@ g_task_set_return_on_cancel (GTask *task,
|
||||
* Since: 2.36
|
||||
*/
|
||||
void
|
||||
g_task_set_source_tag (GTask *task,
|
||||
gpointer source_tag)
|
||||
(g_task_set_source_tag) (GTask *task,
|
||||
gpointer source_tag)
|
||||
{
|
||||
g_return_if_fail (G_IS_TASK (task));
|
||||
|
||||
|
@ -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
|
||||
|
@ -187,6 +187,7 @@ lookup_by_name (GResolver *resolver,
|
||||
data = lookup_data_new (hostname, AF_UNSPEC);
|
||||
task = g_task_new (resolver, cancellable, NULL, NULL);
|
||||
g_task_set_source_tag (task, lookup_by_name);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
g_task_set_task_data (task, data, (GDestroyNotify)lookup_data_free);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread_sync (task, do_lookup_by_name);
|
||||
@ -228,6 +229,7 @@ lookup_by_name_with_flags (GResolver *resolver,
|
||||
data = lookup_data_new (hostname, AF_UNSPEC);
|
||||
task = g_task_new (resolver, cancellable, NULL, NULL);
|
||||
g_task_set_source_tag (task, lookup_by_name_with_flags);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
g_task_set_task_data (task, data, (GDestroyNotify)lookup_data_free);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread_sync (task, do_lookup_by_name);
|
||||
@ -251,6 +253,7 @@ lookup_by_name_with_flags_async (GResolver *resolver,
|
||||
data = lookup_data_new (hostname, flags_to_family (flags));
|
||||
task = g_task_new (resolver, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, lookup_by_name_with_flags_async);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
g_task_set_task_data (task, data, (GDestroyNotify)lookup_data_free);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread (task, do_lookup_by_name);
|
||||
@ -350,6 +353,7 @@ lookup_by_address (GResolver *resolver,
|
||||
|
||||
task = g_task_new (resolver, cancellable, NULL, NULL);
|
||||
g_task_set_source_tag (task, lookup_by_address);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
g_task_set_task_data (task, g_object_ref (address), g_object_unref);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread_sync (task, do_lookup_by_address);
|
||||
@ -370,6 +374,7 @@ lookup_by_address_async (GResolver *resolver,
|
||||
|
||||
task = g_task_new (resolver, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, lookup_by_address_async);
|
||||
g_task_set_name (task, "[gio] resolver lookup");
|
||||
g_task_set_task_data (task, g_object_ref (address), g_object_unref);
|
||||
g_task_set_return_on_cancel (task, TRUE);
|
||||
g_task_run_in_thread (task, do_lookup_by_address);
|
||||
@ -1040,6 +1045,7 @@ lookup_records (GResolver *resolver,
|
||||
|
||||
task = g_task_new (resolver, cancellable, NULL, NULL);
|
||||
g_task_set_source_tag (task, lookup_records);
|
||||
g_task_set_name (task, "[gio] resolver lookup records");
|
||||
|
||||
lrd = g_slice_new (LookupRecordsData);
|
||||
lrd->rrname = g_strdup (rrname);
|
||||
@ -1067,6 +1073,7 @@ lookup_records_async (GResolver *resolver,
|
||||
|
||||
task = g_task_new (resolver, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, lookup_records_async);
|
||||
g_task_set_name (task, "[gio] resolver lookup records");
|
||||
|
||||
lrd = g_slice_new (LookupRecordsData);
|
||||
lrd->rrname = g_strdup (rrname);
|
||||
|
@ -186,6 +186,7 @@ g_tls_database_real_verify_chain_async (GTlsDatabase *self,
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, g_tls_database_real_verify_chain_async);
|
||||
g_task_set_name (task, "[gio] verify TLS chain");
|
||||
g_task_set_task_data (task, args, async_verify_chain_free);
|
||||
g_task_run_in_thread (task, async_verify_chain_thread);
|
||||
g_object_unref (task);
|
||||
@ -264,6 +265,7 @@ g_tls_database_real_lookup_certificate_for_handle_async (GTlsDatabase
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task,
|
||||
g_tls_database_real_lookup_certificate_for_handle_async);
|
||||
g_task_set_name (task, "[gio] lookup TLS certificate");
|
||||
g_task_set_task_data (task, args, async_lookup_certificate_for_handle_free);
|
||||
g_task_run_in_thread (task, async_lookup_certificate_for_handle_thread);
|
||||
g_object_unref (task);
|
||||
@ -338,6 +340,7 @@ g_tls_database_real_lookup_certificate_issuer_async (GTlsDatabase *sel
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task,
|
||||
g_tls_database_real_lookup_certificate_issuer_async);
|
||||
g_task_set_name (task, "[gio] lookup certificate issuer");
|
||||
g_task_set_task_data (task, args, async_lookup_certificate_issuer_free);
|
||||
g_task_run_in_thread (task, async_lookup_certificate_issuer_thread);
|
||||
g_object_unref (task);
|
||||
@ -419,6 +422,7 @@ g_tls_database_real_lookup_certificates_issued_by_async (GTlsDatabase
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task,
|
||||
g_tls_database_real_lookup_certificates_issued_by_async);
|
||||
g_task_set_name (task, "[gio] lookup certificates issued by");
|
||||
g_task_set_task_data (task, args, async_lookup_certificates_issued_by_free);
|
||||
g_task_run_in_thread (task, async_lookup_certificates_issued_by_thread);
|
||||
g_object_unref (task);
|
||||
|
@ -302,7 +302,8 @@ eject_unmount_do (GMount *mount,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data,
|
||||
char **argv)
|
||||
char **argv,
|
||||
const gchar *task_name)
|
||||
{
|
||||
GUnixMount *unix_mount = G_UNIX_MOUNT (mount);
|
||||
GTask *task;
|
||||
@ -310,6 +311,7 @@ eject_unmount_do (GMount *mount,
|
||||
|
||||
task = g_task_new (mount, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, eject_unmount_do);
|
||||
g_task_set_name (task, task_name);
|
||||
g_task_set_task_data (task, g_strdupv (argv), (GDestroyNotify) g_strfreev);
|
||||
|
||||
if (unix_mount->volume_monitor != NULL)
|
||||
@ -337,7 +339,7 @@ g_unix_mount_unmount (GMount *mount,
|
||||
else
|
||||
argv[1] = unix_mount->device_path;
|
||||
|
||||
eject_unmount_do (mount, cancellable, callback, user_data, argv);
|
||||
eject_unmount_do (mount, cancellable, callback, user_data, argv, "[gio] unmount mount");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -363,7 +365,7 @@ g_unix_mount_eject (GMount *mount,
|
||||
else
|
||||
argv[1] = unix_mount->device_path;
|
||||
|
||||
eject_unmount_do (mount, cancellable, callback, user_data, argv);
|
||||
eject_unmount_do (mount, cancellable, callback, user_data, argv, "[gio] eject mount");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -305,7 +305,8 @@ eject_mount_do (GVolume *volume,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data,
|
||||
const gchar * const *argv)
|
||||
const gchar * const *argv,
|
||||
const gchar *task_name)
|
||||
{
|
||||
GSubprocess *subprocess;
|
||||
GError *error = NULL;
|
||||
@ -313,6 +314,7 @@ eject_mount_do (GVolume *volume,
|
||||
|
||||
task = g_task_new (volume, cancellable, callback, user_data);
|
||||
g_task_set_source_tag (task, eject_mount_do);
|
||||
g_task_set_name (task, task_name);
|
||||
|
||||
if (g_task_return_error_if_cancelled (task))
|
||||
{
|
||||
@ -344,7 +346,7 @@ g_unix_volume_mount (GVolume *volume,
|
||||
else
|
||||
argv[1] = unix_volume->device_path;
|
||||
|
||||
eject_mount_do (volume, cancellable, callback, user_data, argv);
|
||||
eject_mount_do (volume, cancellable, callback, user_data, argv, "[gio] mount volume");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -369,7 +371,7 @@ g_unix_volume_eject (GVolume *volume,
|
||||
|
||||
argv[1] = unix_volume->device_path;
|
||||
|
||||
eject_mount_do (volume, cancellable, callback, user_data, argv);
|
||||
eject_mount_do (volume, cancellable, callback, user_data, argv, "[gio] eject volume");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user