[evolution-data-server/openismus-work-3-8] ETransliterator: Use atomic ref counts.



commit 66be9de79d9b7da5e187ee109786d45122d10ba0
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]