mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Merge branch '1175-source-names' into 'master'
gmain: Add names to various GSources constructed in GLib Closes #1175 See merge request GNOME/glib!138
This commit is contained in:
commit
cb2982efe6
@ -648,6 +648,8 @@ g_file_monitor_source_new (gpointer instance,
|
||||
source = g_source_new (&source_funcs, sizeof (GFileMonitorSource));
|
||||
fms = (GFileMonitorSource *) source;
|
||||
|
||||
g_source_set_name (source, "GFileMonitorSource");
|
||||
|
||||
g_mutex_init (&fms->lock);
|
||||
fms->instance = instance;
|
||||
fms->pending_changes = g_sequence_new (pending_change_free);
|
||||
|
@ -1975,6 +1975,7 @@ g_task_thread_pool_init (void)
|
||||
g_thread_pool_set_sort_function (task_pool, g_task_compare_priority, NULL);
|
||||
|
||||
task_pool_manager = g_source_new (&trivial_source_funcs, sizeof (GSource));
|
||||
g_source_set_name (task_pool_manager, "GTask thread pool manager");
|
||||
g_source_set_callback (task_pool_manager, task_pool_manager_timeout, NULL, NULL);
|
||||
g_source_set_ready_time (task_pool_manager, -1);
|
||||
g_source_attach (task_pool_manager,
|
||||
|
71
glib/gmain.c
71
glib/gmain.c
@ -5239,6 +5239,68 @@ unref_unix_signal_handler_unlocked (int signum)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a const string to avoid allocations. We lose precision in the case the
|
||||
* @signum is unrecognised, but that’ll do. */
|
||||
static const gchar *
|
||||
signum_to_string (int signum)
|
||||
{
|
||||
/* See `man 0P signal.h` */
|
||||
#define SIGNAL(s) \
|
||||
case (s): \
|
||||
return ("GUnixSignalSource: " #s);
|
||||
switch (signum)
|
||||
{
|
||||
/* These signals are guaranteed to exist by POSIX. */
|
||||
SIGNAL (SIGABRT)
|
||||
SIGNAL (SIGFPE)
|
||||
SIGNAL (SIGILL)
|
||||
SIGNAL (SIGINT)
|
||||
SIGNAL (SIGSEGV)
|
||||
SIGNAL (SIGTERM)
|
||||
/* Frustratingly, these are not, and hence for brevity the list is
|
||||
* incomplete. */
|
||||
#ifdef SIGALRM
|
||||
SIGNAL (SIGALRM)
|
||||
#endif
|
||||
#ifdef SIGCHLD
|
||||
SIGNAL (SIGCHLD)
|
||||
#endif
|
||||
#ifdef SIGHUP
|
||||
SIGNAL (SIGHUP)
|
||||
#endif
|
||||
#ifdef SIGKILL
|
||||
SIGNAL (SIGKILL)
|
||||
#endif
|
||||
#ifdef SIGPIPE
|
||||
SIGNAL (SIGPIPE)
|
||||
#endif
|
||||
#ifdef SIGQUIT
|
||||
SIGNAL (SIGQUIT)
|
||||
#endif
|
||||
#ifdef SIGSTOP
|
||||
SIGNAL (SIGSTOP)
|
||||
#endif
|
||||
#ifdef SIGUSR1
|
||||
SIGNAL (SIGUSR1)
|
||||
#endif
|
||||
#ifdef SIGUSR2
|
||||
SIGNAL (SIGUSR2)
|
||||
#endif
|
||||
#ifdef SIGPOLL
|
||||
SIGNAL (SIGPOLL)
|
||||
#endif
|
||||
#ifdef SIGPROF
|
||||
SIGNAL (SIGPROF)
|
||||
#endif
|
||||
#ifdef SIGTRAP
|
||||
SIGNAL (SIGTRAP)
|
||||
#endif
|
||||
default:
|
||||
return "GUnixSignalSource: Unrecognized signal";
|
||||
}
|
||||
#undef SIGNAL
|
||||
}
|
||||
|
||||
GSource *
|
||||
_g_main_create_unix_signal_watch (int signum)
|
||||
{
|
||||
@ -5251,6 +5313,9 @@ _g_main_create_unix_signal_watch (int signum)
|
||||
unix_signal_source->signum = signum;
|
||||
unix_signal_source->pending = FALSE;
|
||||
|
||||
/* Set a default name on the source, just in case the caller does not. */
|
||||
g_source_set_name (source, signum_to_string (signum));
|
||||
|
||||
G_LOCK (unix_signal_lock);
|
||||
ref_unix_signal_handler_unlocked (signum);
|
||||
unix_signal_watches = g_slist_prepend (unix_signal_watches, unix_signal_source);
|
||||
@ -5379,6 +5444,9 @@ g_child_watch_source_new (GPid pid)
|
||||
source = g_source_new (&g_child_watch_funcs, sizeof (GChildWatchSource));
|
||||
child_watch_source = (GChildWatchSource *)source;
|
||||
|
||||
/* Set a default name on the source, just in case the caller does not. */
|
||||
g_source_set_name (source, "GChildWatchSource");
|
||||
|
||||
child_watch_source->pid = pid;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
@ -5565,6 +5633,9 @@ g_idle_source_new (void)
|
||||
source = g_source_new (&g_idle_funcs, sizeof (GSource));
|
||||
g_source_set_priority (source, G_PRIORITY_DEFAULT_IDLE);
|
||||
|
||||
/* Set a default name on the source, just in case the caller does not. */
|
||||
g_source_set_name (source, "GIdleSource");
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user