Commit 4e12e7ed authored by Philip Withnall's avatar Philip Withnall

Merge branch 'th/main-context-default-no-mutex' into 'master'

gmain: use atomic operation instead of GMutex to access g_main_context_default()

See merge request !1135
parents 038ec3de 39dd2be5
Pipeline #121500 failed with stages
in 13 minutes and 34 seconds
......@@ -439,9 +439,6 @@ static void block_source (GSource *source);
static GMainContext *glib_worker_context;
static GMainContext *default_main_context;
#ifndef G_OS_WIN32
......@@ -667,34 +664,35 @@ g_main_context_new (void)
* g_main_context_default:
* Returns the global default main context. This is the main context
* used for main loop functions when a main loop is not explicitly
* specified, and corresponds to the "main" main loop. See also
* g_main_context_get_thread_default().
* Returns: (transfer none): the global default main context.
GMainContext *
g_main_context_default (void)
/* Slow, but safe */
G_LOCK (main_loop);
static GMainContext *default_main_context;
if (!default_main_context)
if (g_once_init_enter (&default_main_context))
default_main_context = g_main_context_new ();
GMainContext *context;
context = g_main_context_new ();
TRACE (GLIB_MAIN_CONTEXT_DEFAULT (default_main_context));
if (_g_main_poll_debug)
g_print ("default context=%p\n", default_main_context);
g_print ("default context=%p\n", context);
G_UNLOCK (main_loop);
g_once_init_leave ((gsize *) &default_main_context, (gsize) context);
return default_main_context;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment