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/10/15 17:34:35 UTC

svn commit: r825522 - /activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs

Author: tabish
Date: Thu Oct 15 15:34:34 2009
New Revision: 825522

URL: http://svn.apache.org/viewvc?rev=825522&view=rev
Log:
Change to make the nextCommandId an int instead of a short to prevent quickly exhausting the available set of command Ids before the broker has processed large batches of messages.  Also changed the Id increment to use the Interlocked increment instead of a mutex.

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

Modified: activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs?rev=825522&r1=825521&r2=825522&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.ActiveMQ/trunk/src/main/csharp/Transport/ResponseCorrelator.cs Thu Oct 15 15:34:34 2009
@@ -16,6 +16,7 @@
  */
 
 using System;
+using System.Threading;
 using System.Collections;
 
 using Apache.NMS.ActiveMQ.Commands;
@@ -30,8 +31,7 @@
 	public class ResponseCorrelator : TransportFilter
 	{
 		private readonly IDictionary requestMap = Hashtable.Synchronized(new Hashtable());
-		private readonly Object mutex = new Object();
-		private short nextCommandId;
+		private int nextCommandId;
 
 		public ResponseCorrelator(ITransport next) : base(next)
 		{
@@ -55,12 +55,9 @@
 			requestMap.Clear();
 		}
 
-		short GetNextCommandId()
+		int GetNextCommandId()
 		{
-			lock(mutex)
-			{
-				return ++nextCommandId;
-			}
+            return Interlocked.Increment(ref nextCommandId);
 		}
 
 		public override void Oneway(Command command)