[glib: 9/12] tests: Use separate GMainContext in thread in spawn-multithreaded
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 9/12] tests: Use separate GMainContext in thread in spawn-multithreaded
- Date: Mon, 14 Mar 2022 12:52:45 +0000 (UTC)
commit ca99cf032d85de4eed7affb084aa43823ddb7cf7
Author: Philip Withnall <pwithnall endlessos org>
Date: Sat Mar 12 01:30:00 2022 +0000
tests: Use separate GMainContext in thread in spawn-multithreaded
Otherwise the `start_thread()` threads and the main thread are competing
to iterate the global default context, which is probably not what was
intended.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
glib/tests/spawn-multithreaded.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/spawn-multithreaded.c b/glib/tests/spawn-multithreaded.c
index 05eded1cc..51e21d651 100644
--- a/glib/tests/spawn-multithreaded.c
+++ b/glib/tests/spawn-multithreaded.c
@@ -112,8 +112,10 @@ start_thread (gpointer user_data)
GPid pid;
SpawnChildsData *data = user_data;
gint ttl = data->ttl;
+ GMainContext *new_main_context = NULL;
- new_main_loop = g_main_loop_new (NULL, FALSE);
+ new_main_context = g_main_context_new ();
+ new_main_loop = g_main_loop_new (new_main_context, FALSE);
pid = get_a_child (ttl);
source = g_child_watch_source_new (pid);
@@ -126,6 +128,7 @@ start_thread (gpointer user_data)
g_main_loop_run (new_main_loop);
g_main_loop_unref (new_main_loop);
+ g_main_context_unref (new_main_context);
return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]