mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 16:06:16 +01:00
gvarianttypeinfo: Use gatomicrefcount for ContainerInfo reference count
This commit is contained in:
parent
6d108587a4
commit
b5a41afb18
@ -26,6 +26,7 @@
|
||||
#include <glib/gthread.h>
|
||||
#include <glib/gslice.h>
|
||||
#include <glib/ghash.h>
|
||||
#include <glib/grefcount.h>
|
||||
|
||||
/* < private >
|
||||
* GVariantTypeInfo:
|
||||
@ -76,7 +77,7 @@ typedef struct
|
||||
GVariantTypeInfo info;
|
||||
|
||||
gchar *type_string;
|
||||
gint ref_count;
|
||||
gatomicrefcount ref_count;
|
||||
} ContainerInfo;
|
||||
|
||||
/* For 'array' and 'maybe' types, we store some extra information on the
|
||||
@ -167,7 +168,7 @@ g_variant_type_info_check (const GVariantTypeInfo *info,
|
||||
ContainerInfo *container = (ContainerInfo *) info;
|
||||
|
||||
/* extra checks for containers */
|
||||
g_assert_cmpint (g_atomic_int_get (&container->ref_count), >, 0);
|
||||
g_assert (!g_atomic_ref_count_compare (&container->ref_count, 0));
|
||||
g_assert (container->type_string != NULL);
|
||||
}
|
||||
else
|
||||
@ -788,7 +789,7 @@ g_variant_type_info_get (const GVariantType *type)
|
||||
|
||||
info = (GVariantTypeInfo *) container;
|
||||
container->type_string = type_string;
|
||||
container->ref_count = 1;
|
||||
g_atomic_ref_count_init (&container->ref_count);
|
||||
|
||||
g_hash_table_insert (g_variant_type_info_table, type_string, info);
|
||||
type_string = NULL;
|
||||
@ -834,8 +835,7 @@ g_variant_type_info_ref (GVariantTypeInfo *info)
|
||||
{
|
||||
ContainerInfo *container = (ContainerInfo *) info;
|
||||
|
||||
g_assert_cmpint (g_atomic_int_get (&container->ref_count), >, 0);
|
||||
g_atomic_int_inc (&container->ref_count);
|
||||
g_atomic_ref_count_inc (&container->ref_count);
|
||||
}
|
||||
|
||||
return info;
|
||||
@ -858,7 +858,7 @@ g_variant_type_info_unref (GVariantTypeInfo *info)
|
||||
ContainerInfo *container = (ContainerInfo *) info;
|
||||
|
||||
g_rec_mutex_lock (&g_variant_type_info_lock);
|
||||
if (g_atomic_int_dec_and_test (&container->ref_count))
|
||||
if (g_atomic_ref_count_dec (&container->ref_count))
|
||||
{
|
||||
g_hash_table_remove (g_variant_type_info_table,
|
||||
container->type_string);
|
||||
|
Loading…
Reference in New Issue
Block a user