[gupnp] resource-factory: Use GOnce for singleton
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp] resource-factory: Use GOnce for singleton
- Date: Sat, 14 Aug 2021 07:56:03 +0000 (UTC)
commit eb7e1d26c5d0b21d1cd9f9a781385bd224a509a9
Author: Jens Georg <mail jensge org>
Date: Sat Aug 14 09:19:28 2021 +0200
resource-factory: Use GOnce for singleton
libgupnp/gupnp-resource-factory.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/libgupnp/gupnp-resource-factory.c b/libgupnp/gupnp-resource-factory.c
index 8d7e362..9ab34db 100644
--- a/libgupnp/gupnp-resource-factory.c
+++ b/libgupnp/gupnp-resource-factory.c
@@ -114,9 +114,11 @@ gupnp_resource_factory_get_default (void)
{
static GUPnPResourceFactory *default_factory = NULL;
- if (G_UNLIKELY (default_factory == NULL)) {
- default_factory = g_object_new (GUPNP_TYPE_RESOURCE_FACTORY,
- NULL);
+ if (g_once_init_enter (&default_factory)) {
+ GUPnPResourceFactory *factory =
+ g_object_new (GUPNP_TYPE_RESOURCE_FACTORY, NULL);
+
+ g_once_init_leave (&default_factory, factory);
}
return default_factory;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]