activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1063057 - /activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/MessageDispatchChannel.cs
Date Mon, 24 Jan 2011 23:19:27 GMT
Author: tabish
Date: Mon Jan 24 23:19:26 2011
New Revision: 1063057

URL: http://svn.apache.org/viewvc?rev=1063057&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQNET-309

Fixes the code so it works on .NETCF but limits the class such that it only works well if
there's only one thread waiting on the channel.  Should allow all tests to pass while we see
if we can get a version of WaitAny to work on .NETCF

Modified:
    activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/MessageDispatchChannel.cs

Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/MessageDispatchChannel.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/MessageDispatchChannel.cs?rev=1063057&r1=1063056&r2=1063057&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/MessageDispatchChannel.cs
(original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Util/MessageDispatchChannel.cs
Mon Jan 24 23:19:26 2011
@@ -25,16 +25,13 @@ namespace Apache.NMS.Stomp.Util
     public class MessageDispatchChannel
     {
         private readonly Mutex mutex = new Mutex();
-        private readonly ManualResetEvent wakeAll = new ManualResetEvent(false);
-        private readonly AutoResetEvent waiter = new AutoResetEvent(false);
-        private WaitHandle[] waiters;
+        private readonly ManualResetEvent waiter = new ManualResetEvent(false);
         private bool closed;
         private bool running;
         private readonly LinkedList<MessageDispatch> channel = new LinkedList<MessageDispatch>();
 
         public MessageDispatchChannel()
         {
-            this.waiters = new WaitHandle[] { this.waiter, this.wakeAll };
         }
 
         #region Properties
@@ -113,7 +110,7 @@ namespace Apache.NMS.Stomp.Util
                 if(!Closed)
                 {
                     this.running = true;
-                    this.wakeAll.Reset();
+                    this.waiter.Reset();
                 }
             }
         }
@@ -123,7 +120,7 @@ namespace Apache.NMS.Stomp.Util
             lock(mutex)
             {
                 this.running = false;
-                this.wakeAll.Set();
+                this.waiter.Set();
             }
         }
 
@@ -137,7 +134,7 @@ namespace Apache.NMS.Stomp.Util
                     this.closed = true;
                 }
 
-                this.wakeAll.Set();
+                this.waiter.Set();
             }
         }
 
@@ -168,9 +165,15 @@ namespace Apache.NMS.Stomp.Util
             // Wait until the channel is ready to deliver messages.
             if( timeout != TimeSpan.Zero && !Closed && ( Empty || !Running
) )
             {
-                this.mutex.ReleaseMutex();
+                // This isn't the greatest way to do this but to work on the
+                // .NETCF its the only solution I could find so far.  This
+                // code will only really work for one Thread using the event
+                // channel to wait as all waiters are going to drop out of
+                // here regardless of the fact that only one message could
+                // be on the Queue.  
                 this.waiter.Reset();
-                ThreadUtil.WaitAny(this.waiters, (int)timeout.TotalMilliseconds, false);
+                this.mutex.ReleaseMutex();
+                this.waiter.WaitOne((int)timeout.TotalMilliseconds, false);
                 this.mutex.WaitOne();
             }
 



Mime
View raw message