mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 12:25:48 +01:00
gresource: Use atomic pointer exchange operations to nullify and check
This commit is contained in:
parent
9c32cfbaaa
commit
bfd77693ce
@ -1443,14 +1443,13 @@ g_static_resource_fini (GStaticResource *static_resource)
|
|||||||
|
|
||||||
register_lazy_static_resources_unlocked ();
|
register_lazy_static_resources_unlocked ();
|
||||||
|
|
||||||
resource = g_atomic_pointer_get (&static_resource->resource);
|
resource = g_atomic_pointer_exchange (&static_resource->resource, NULL);
|
||||||
if (resource)
|
if (resource)
|
||||||
{
|
{
|
||||||
/* There should be at least two references to the resource now: one for
|
/* There should be at least two references to the resource now: one for
|
||||||
* static_resource->resource, and one in the registered_resources list. */
|
* static_resource->resource, and one in the registered_resources list. */
|
||||||
g_assert (g_atomic_int_get (&resource->ref_count) >= 2);
|
g_assert (g_atomic_int_get (&resource->ref_count) >= 2);
|
||||||
|
|
||||||
g_atomic_pointer_set (&static_resource->resource, NULL);
|
|
||||||
g_resources_unregister_unlocked (resource);
|
g_resources_unregister_unlocked (resource);
|
||||||
g_resource_unref (resource);
|
g_resource_unref (resource);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user