[blam] Use Interlocking for reference counting
- From: Carlos MartÃn Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam] Use Interlocking for reference counting
- Date: Tue, 23 Aug 2011 18:34:41 +0000 (UTC)
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]