mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
Port various timeout/idle callbacks to the once API
So we excercise it in our test coverage.
This commit is contained in:
parent
12571a0821
commit
50c316ef36
@ -85,13 +85,12 @@ map_or_die (const gchar *filename,
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
signal_parent (gpointer data)
|
signal_parent (gpointer data)
|
||||||
{
|
{
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
kill (parent_pid, SIGUSR1);
|
kill (parent_pid, SIGUSR1);
|
||||||
#endif
|
#endif
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -113,7 +112,7 @@ child_main (void)
|
|||||||
#endif
|
#endif
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
g_idle_add (check_stop, loop);
|
g_idle_add (check_stop, loop);
|
||||||
g_idle_add (signal_parent, NULL);
|
g_idle_add_once (signal_parent, NULL);
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
|
|
||||||
g_test_message ("test_child_private: received parent signal");
|
g_test_message ("test_child_private: received parent signal");
|
||||||
|
@ -5,12 +5,10 @@
|
|||||||
|
|
||||||
static GMainLoop *loop;
|
static GMainLoop *loop;
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
stop_waiting (gpointer data)
|
stop_waiting (gpointer data)
|
||||||
{
|
{
|
||||||
g_main_loop_quit (loop);
|
g_main_loop_quit (loop);
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -44,7 +42,7 @@ test_seconds (void)
|
|||||||
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=642052");
|
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=642052");
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
g_timeout_add (2100, stop_waiting, NULL);
|
g_timeout_add_once (2100, stop_waiting, NULL);
|
||||||
id = g_timeout_add_seconds (21475, unreachable_callback, NULL);
|
id = g_timeout_add_seconds (21475, unreachable_callback, NULL);
|
||||||
|
|
||||||
g_main_loop_run (loop);
|
g_main_loop_run (loop);
|
||||||
@ -81,7 +79,7 @@ test_weeks_overflow (void)
|
|||||||
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/1600");
|
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/1600");
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
|
||||||
g_timeout_add (2100, stop_waiting, NULL);
|
g_timeout_add_once (2100, stop_waiting, NULL);
|
||||||
interval_seconds = 1 + G_MAXUINT / 1000;
|
interval_seconds = 1 + G_MAXUINT / 1000;
|
||||||
id = g_timeout_add_seconds (interval_seconds, unreachable_callback, NULL);
|
id = g_timeout_add_seconds (interval_seconds, unreachable_callback, NULL);
|
||||||
|
|
||||||
|
@ -767,11 +767,10 @@ test_os_info (void)
|
|||||||
g_free (contents);
|
g_free (contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
source_test (gpointer data)
|
source_test (gpointer data)
|
||||||
{
|
{
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
return G_SOURCE_REMOVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -779,13 +778,13 @@ test_clear_source (void)
|
|||||||
{
|
{
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
id = g_idle_add (source_test, NULL);
|
id = g_idle_add_once (source_test, NULL);
|
||||||
g_assert_cmpuint (id, >, 0);
|
g_assert_cmpuint (id, >, 0);
|
||||||
|
|
||||||
g_clear_handle_id (&id, g_source_remove);
|
g_clear_handle_id (&id, g_source_remove);
|
||||||
g_assert_cmpuint (id, ==, 0);
|
g_assert_cmpuint (id, ==, 0);
|
||||||
|
|
||||||
id = g_timeout_add (100, source_test, NULL);
|
id = g_timeout_add_once (100, source_test, NULL);
|
||||||
g_assert_cmpuint (id, >, 0);
|
g_assert_cmpuint (id, >, 0);
|
||||||
|
|
||||||
g_clear_handle_id (&id, g_source_remove);
|
g_clear_handle_id (&id, g_source_remove);
|
||||||
|
Loading…
Reference in New Issue
Block a user