Author: jbevain
Date: 2007-11-07 06:06:59 -0500 (Wed, 07 Nov 2007)
New Revision: 89090
Modified:
trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/BrowserHttpWebAsyncResult.cs
trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/ChangeLog
Log:
2007-11-07 Jb Evain <[EMAIL PROTECTED]>
* BrowserHttpWebAsyncResult.cs: implement this cutie.
Modified:
trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/BrowserHttpWebAsyncResult.cs
===================================================================
---
trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/BrowserHttpWebAsyncResult.cs
2007-11-07 11:05:35 UTC (rev 89089)
+++
trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/BrowserHttpWebAsyncResult.cs
2007-11-07 11:06:59 UTC (rev 89090)
@@ -36,25 +36,73 @@
using Mono;
+// I took this implementation from here:
+//
http://www.bluebytesoftware.com/blog/2006/05/31/ImplementingAHighperfIAsyncResultLockfreeLazyAllocation.aspx
+// Thanks Joe!
+
namespace System.Windows.Browser.Net
{
- class BrowserHttpWebAsyncResult : IAsyncResult
+ class BrowserHttpWebAsyncResult : IAsyncResult, IDisposable
{
+ object state;
+ bool completed;
+ AsyncCallback callback;
+ ManualResetEvent wait_handle;
+
public object AsyncState {
get { throw new NotImplementedException (); }
}
public WaitHandle AsyncWaitHandle {
- get { throw new NotImplementedException (); }
+ get {
+ if (wait_handle != null)
+ return wait_handle;
+
+ ManualResetEvent new_handle = new
ManualResetEvent (false);
+ if (Interlocked.CompareExchange (ref
wait_handle, new_handle, null) != null)
+ new_handle.Close ();
+
+ if (completed)
+ wait_handle.Set ();
+
+ return wait_handle;
+ }
}
public bool CompletedSynchronously {
- get { throw new NotImplementedException (); }
+ get { return false; }
}
public bool IsCompleted {
- get { throw new NotImplementedException (); }
+ get { return completed; }
}
+
+ public BrowserHttpWebAsyncResult (AsyncCallback callback,
object state)
+ {
+ this.callback = callback;
+ this.state = state;
+ }
+
+ public void SetComplete ()
+ {
+ completed = true;
+
+ Helper.ThreadMemoryBarrier ();
+
+ if (wait_handle != null)
+ wait_handle.Set ();
+
+ if (callback != null)
+ callback (this);
+ }
+
+ public void Dispose ()
+ {
+ if (wait_handle == null)
+ return;
+
+ wait_handle.Close ();
+ }
}
}
Modified:
trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/ChangeLog
===================================================================
--- trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/ChangeLog
2007-11-07 11:05:35 UTC (rev 89089)
+++ trunk/olive/class/System.Silverlight/System.Windows.Browser.Net/ChangeLog
2007-11-07 11:06:59 UTC (rev 89090)
@@ -1,5 +1,9 @@
2007-11-07 Jb Evain <[EMAIL PROTECTED]>
+ * BrowserHttpWebAsyncResult.cs: implement this cutie.
+
+2007-11-07 Jb Evain <[EMAIL PROTECTED]>
+
* BrowserHttpWebAsyncResult.cs: Create a stub to be used
to invoke responses asynchronously.
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches