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 2010/01/11 21:01:48 UTC
svn commit: r898036 - in
/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp:
Protocol/StompWireFormat.cs Threads/DedicatedTaskRunner.cs
Author: tabish
Date: Mon Jan 11 20:01:48 2010
New Revision: 898036
URL: http://svn.apache.org/viewvc?rev=898036&view=rev
Log:
Update the protocol encoding and port the DedicatedTaskRunner to build on .NET CF 2.0
Modified:
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs
Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs?rev=898036&r1=898035&r2=898036&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Protocol/StompWireFormat.cs Mon Jan 11 20:01:48 2010
@@ -322,9 +322,14 @@
// Store the Marshaled Content.
frame.Content = command.Content;
- if(command is BytesMessage && command.Content != null && command.Content.Length > 0)
+ if(command is BytesMessage)
{
- frame.SetProperty("content-length", command.Content.Length);
+ if(command.Content != null && command.Content.Length > 0)
+ {
+ frame.SetProperty("content-length", command.Content.Length);
+ }
+
+ frame.SetProperty("transformation", "jms-byte");
}
// Marshal all properties to the Frame.
@@ -401,7 +406,7 @@
}
// ActiveMQ extensions to STOMP
- frame.SetProperty("transformation", "jms-map-xml");
+ // frame.SetProperty("transformation", "jms-map-xml");
frame.SetProperty("activemq.dispatchAsync", command.DispatchAsync);
if(command.Exclusive)
Modified: activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs?rev=898036&r1=898035&r2=898036&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.Stomp/trunk/src/main/csharp/Threads/DedicatedTaskRunner.cs Mon Jan 11 20:01:48 2010
@@ -26,6 +26,8 @@
public class DedicatedTaskRunner : TaskRunner
{
private readonly Mutex mutex = new Mutex();
+ private readonly AutoResetEvent waiter = new AutoResetEvent(false);
+ private readonly ManualResetEvent isShutdown = new ManualResetEvent(true);
private Thread theThread = null;
private Task task = null;
@@ -49,25 +51,46 @@
public void Shutdown(TimeSpan timeout)
{
- lock(mutex)
- {
- this.shutdown = true;
- this.pending = true;
+ Monitor.Enter(this.mutex);
- Monitor.PulseAll(this.mutex);
+ this.shutdown = true;
+ this.pending = true;
- // Wait till the thread stops ( no need to wait if shutdown
- // is called from thread that is shutting down)
- if(Thread.CurrentThread != this.theThread && !this.terminated)
- {
- Monitor.Wait(this.mutex, timeout);
- }
+ this.waiter.Set();
+
+ // Wait till the thread stops ( no need to wait if shutdown
+ // is called from thread that is shutting down)
+ if(Thread.CurrentThread != this.theThread && !this.terminated)
+ {
+ Monitor.Exit(this.mutex);
+ this.isShutdown.WaitOne(timeout.Milliseconds);
+ }
+ else
+ {
+ Monitor.Exit(this.mutex);
}
}
public void Shutdown()
{
- this.Shutdown(TimeSpan.FromMilliseconds(-1));
+ Monitor.Enter(this.mutex);
+
+ this.shutdown = true;
+ this.pending = true;
+
+ this.waiter.Set();
+
+ // Wait till the thread stops ( no need to wait if shutdown
+ // is called from thread that is shutting down)
+ if(Thread.CurrentThread != this.theThread && !this.terminated)
+ {
+ Monitor.Exit(this.mutex);
+ this.isShutdown.WaitOne();
+ }
+ else
+ {
+ Monitor.Exit(this.mutex);
+ }
}
public void Wakeup()
@@ -81,12 +104,17 @@
this.pending = true;
- Monitor.PulseAll(this.mutex);
+ this.waiter.Set();
}
}
internal void Run()
{
+ lock(this.mutex)
+ {
+ this.isShutdown.Reset();
+ }
+
try
{
while(true)
@@ -97,7 +125,6 @@
if(this.shutdown)
{
-
return;
}
}
@@ -105,18 +132,19 @@
if(!this.task.Iterate())
{
// wait to be notified.
- lock(this.mutex)
+ Monitor.Enter(this.mutex);
+ if(this.shutdown)
{
- if(this.shutdown)
- {
- return;
- }
-
- while(!this.pending)
- {
- Monitor.Wait(this.mutex);
- }
+ return;
+ }
+
+ while(!this.pending)
+ {
+ Monitor.Exit(this.mutex);
+ this.waiter.WaitOne();
+ Monitor.Enter(this.mutex);
}
+ Monitor.Exit(this.mutex);
}
}
}
@@ -127,11 +155,12 @@
{
// Make sure we notify any waiting threads that thread
// has terminated.
- lock(this.mutex)
- {
- this.terminated = true;
- Monitor.PulseAll(this.mutex);
- }
+ //lock(this.mutex)
+ //{
+ Monitor.Enter(this.mutex);
+ this.terminated = true;
+ Monitor.Exit(this.mutex);
+ this.isShutdown.Set();
}
}
}