activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r775121 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
Date Fri, 15 May 2009 13:09:53 GMT
Author: tabish
Date: Fri May 15 13:09:52 2009
New Revision: 775121

URL: http://svn.apache.org/viewvc?rev=775121&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQNET-132

Use an AtomicBoolean for the closed marker, it doesn't need to lock on this for this simple
test value.

Modified:
    activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs?rev=775121&r1=775120&r2=775121&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs
Fri May 15 13:09:52 2009
@@ -17,6 +17,7 @@
 using System;
 using Apache.NMS.ActiveMQ.Commands;
 using Apache.NMS;
+using Apache.NMS.Util;
 
 namespace Apache.NMS.ActiveMQ
 {
@@ -34,7 +35,7 @@
 	public class MessageConsumer : IMessageConsumer
 	{
 		private readonly AcknowledgementMode acknowledgementMode;
-		private bool closed = false;
+		private AtomicBoolean closed = new AtomicBoolean( false );
 		private readonly Dispatcher dispatcher = new Dispatcher();
 		private readonly ConsumerInfo info;
 		private int maximumRedeliveryCount = 10;
@@ -151,7 +152,7 @@
 		{
 			lock(this)
 			{
-				if(closed)
+				if(closed.Value)
 				{
 					return;
 				}
@@ -174,7 +175,7 @@
 
 				session = null;
 				ackSession = null;
-				closed = true;
+				closed.Value = true;
 			}
 		}
 
@@ -228,12 +229,9 @@
 
 		protected void CheckClosed()
 		{
-			lock(this)
+			if(closed.Value)
 			{
-				if(closed)
-				{
-					throw new ConnectionClosedException();
-				}
+				throw new ConnectionClosedException();
 			}
 		}
 



Mime
View raw message