[glib: 2/4] gvarianttypeinfo: Use gatomicrefcount for ContainerInfo reference count
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/4] gvarianttypeinfo: Use gatomicrefcount for ContainerInfo reference count
- Date: Thu, 8 Nov 2018 14:22:26 +0000 (UTC)
commit b5a41afb18c9c5b6daf0eaa164335d825820c5c7
Author: Tomasz Miąsko <tomasz miasko gmail com>
Date: Fri Nov 2 00:00:00 2018 +0000
gvarianttypeinfo: Use gatomicrefcount for ContainerInfo reference count
glib/gvarianttypeinfo.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/glib/gvarianttypeinfo.c b/glib/gvarianttypeinfo.c
index 399b610c8..d5deae6af 100644
--- a/glib/gvarianttypeinfo.c
+++ b/glib/gvarianttypeinfo.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]