mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-12 23:53:46 +02:00
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>
This commit is contained in:
parent
54748d3b7c
commit
ca99cf032d
@ -112,8 +112,10 @@ start_thread (gpointer user_data)
|
|||||||
GPid pid;
|
GPid pid;
|
||||||
SpawnChildsData *data = user_data;
|
SpawnChildsData *data = user_data;
|
||||||
gint ttl = data->ttl;
|
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);
|
pid = get_a_child (ttl);
|
||||||
source = g_child_watch_source_new (pid);
|
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_run (new_main_loop);
|
||||||
g_main_loop_unref (new_main_loop);
|
g_main_loop_unref (new_main_loop);
|
||||||
|
g_main_context_unref (new_main_context);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user