giomodule: Don’t mandatorily cache GIOModule implementations

While all of the current callers of _g_io_module_get_default() want to
cache the returned GObject for the lifetime of the process, that doesn’t
necessarily have to be the case, so let callers make that decision on a
case-by-case basis.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall
2019-01-23 16:07:51 +00:00
committed by Philip Withnall
parent b207965697
commit 22b924b64a
7 changed files with 121 additions and 31 deletions

View File

@@ -93,6 +93,8 @@ g_tls_backend_default_init (GTlsBackendInterface *iface)
{
}
static GTlsBackend *tls_backend_default_singleton = NULL; /* (owned) (atomic) */
/**
* g_tls_backend_get_default:
*
@@ -106,8 +108,18 @@ g_tls_backend_default_init (GTlsBackendInterface *iface)
GTlsBackend *
g_tls_backend_get_default (void)
{
return _g_io_module_get_default (G_TLS_BACKEND_EXTENSION_POINT_NAME,
"GIO_USE_TLS", NULL);
if (g_once_init_enter (&tls_backend_default_singleton))
{
GTlsBackend *singleton;
singleton = _g_io_module_get_default (G_TLS_BACKEND_EXTENSION_POINT_NAME,
"GIO_USE_TLS",
NULL);
g_once_init_leave (&tls_backend_default_singleton, singleton);
}
return tls_backend_default_singleton;
}
/**