[blam] Use Interlocking for reference counting



commit 82d318a8c5bdfe9819ec856b3122d0de662c3fb4
Author: Carlos MartÃn Nieto <carlos cmartin tk>
Date:   Tue Aug 23 20:29:11 2011 +0200

    Use Interlocking for reference counting

 src/Item.cs |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)
---
diff --git a/src/Item.cs b/src/Item.cs
index 50756fa..caaca62 100644
--- a/src/Item.cs
+++ b/src/Item.cs
@@ -6,6 +6,7 @@
 
 using System.Xml.Serialization;
 using System;
+using System.Threading;
 using System.ServiceModel.Syndication;
 
 namespace Imendio.Blam {
@@ -49,24 +50,18 @@ namespace Imendio.Blam {
 
         public int RefCount {
             get {
-                lock(obj){
-                    return ref_cnt;
-                }
+                return ref_cnt;
             }
         }
 
         public void Grab()
         {
-            lock(obj){
-                ++ref_cnt;
-            }
+            Interlocked.Increment(ref ref_cnt);
         }
 
         public void Release()
         {
-            lock(obj){
-                --ref_cnt;
-            }
+            Interlocked.Decrement(ref ref_cnt);
         }
 
 		public Item ()



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