mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
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
This commit is contained in:
parent
e5696c282e
commit
6b53e4826f
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user