[glib] GSource: add g_source_set_name, g_source_get_name, g_source_set_name_by_id
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GSource: add g_source_set_name, g_source_get_name, g_source_set_name_by_id
- Date: Tue, 25 May 2010 20:59:29 +0000 (UTC)
commit 6b53e4826fba3827ac7273a344b46f854ee81d0b
Author: Havoc Pennington <hp pobox com>
Date: Tue Apr 20 17:47:44 2010 -0400
GSource: add g_source_set_name, g_source_get_name, g_source_set_name_by_id
These allow applications to give meaningful names to their sources.
Source names can then be used for debugging and profiling, for
example with systemtap or gdb.
https://bugzilla.gnome.org/show_bug.cgi?id=606044
glib/gmain.c | 5 ++++-
tests/mainloop-test.c | 6 +++++-
2 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/glib/gmain.c b/glib/gmain.c
index 048d834..32b1d21 100644
--- a/glib/gmain.c
+++ b/glib/gmain.c
@@ -1415,7 +1415,10 @@ g_source_unref_internal (GSource *source,
if (source->source_funcs->finalize)
source->source_funcs->finalize (source);
-
+
+ g_free (source->name);
+ source->name = NULL;
+
g_slist_free (source->poll_fds);
source->poll_fds = NULL;
g_free (source);
diff --git a/tests/mainloop-test.c b/tests/mainloop-test.c
index cfa7f73..5fa7931 100644
--- a/tests/mainloop-test.c
+++ b/tests/mainloop-test.c
@@ -156,13 +156,15 @@ adder_thread (gpointer data)
addr_data.dest = channels[1];
addr_data.loop = g_main_loop_new (context, FALSE);
addr_data.count = 0;
-
+
adder_source = g_io_create_watch (channels[0], G_IO_IN | G_IO_HUP);
+ g_source_set_name (source, "Adder I/O");
g_source_set_callback (adder_source, (GSourceFunc)adder_callback, &addr_data, NULL);
g_source_attach (adder_source, context);
g_source_unref (adder_source);
timeout_source = g_timeout_source_new (10);
+ g_source_set_name (source, "Adder timeout");
g_source_set_callback (timeout_source, (GSourceFunc)timeout_callback, &addr_data, NULL);
g_source_set_priority (timeout_source, G_PRIORITY_HIGH);
g_source_attach (timeout_source, context);
@@ -335,6 +337,7 @@ static void
create_crawler (void)
{
GSource *source = g_timeout_source_new (g_random_int_range (0, CRAWLER_TIMEOUT_RANGE));
+ g_source_set_name (source, "Crawler timeout");
g_source_set_callback (source, (GSourceFunc)crawler_callback, source, NULL);
G_LOCK (crawler_array_lock);
@@ -386,6 +389,7 @@ recurser_start (gpointer data)
g_mutex_lock (context_array_mutex);
context = context_array->pdata[g_random_int_range (0, context_array->len)];
source = g_idle_source_new ();
+ g_source_set_name (source, "Recursing idle source");
g_source_set_callback (source, recurser_idle, context, NULL);
g_source_attach (source, context);
g_source_unref (source);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]