You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ta...@apache.org on 2009/05/15 15:09:53 UTC

svn commit: r775121 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/MessageConsumer.cs

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();
 			}
 		}