[evolution-data-server/october-code-drop-post-api-change: 39/39] ETransliterator: Use atomic ref counts.



commit 90f9948ab2e2b846efd81deb4293e7a33b406559
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Thu Oct 24 23:24:27 2013 +0200

    ETransliterator: Use atomic ref counts.

 libedataserver/e-transliterator.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
---
diff --git a/libedataserver/e-transliterator.c b/libedataserver/e-transliterator.c
index 68fe960..4129b75 100644
--- a/libedataserver/e-transliterator.c
+++ b/libedataserver/e-transliterator.c
@@ -50,7 +50,7 @@ struct _ETransliterator
 {
        ECxxTransliterator *transliterator;
 
-       gint                ref_count;
+       volatile gint       ref_count;
 };
 
 /*****************************************************
@@ -105,7 +105,7 @@ e_transliterator_ref (ETransliterator *transliterator)
 {
        g_return_val_if_fail (transliterator != NULL, NULL);
 
-       transliterator->ref_count++;
+       g_atomic_int_inc (&transliterator->ref_count);
 
        return transliterator;
 }
@@ -124,12 +124,7 @@ e_transliterator_unref (ETransliterator *transliterator)
 {
        g_return_if_fail (transliterator != NULL);
 
-       transliterator->ref_count--;
-
-       if (transliterator->ref_count < 0)
-               g_warning ("Unbalanced reference count in ETransliterator");
-
-       if (transliterator->ref_count == 0) {
+       if (g_atomic_int_dec_and_test (&transliterator->ref_count)) {
 
                if (transliterator->transliterator)
                        _e_transliterator_cxx_free (transliterator->transliterator);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]