Author: gonzalo
Date: 2005-04-07 20:17:16 -0400 (Thu, 07 Apr 2005)
New Revision: 42667

Modified:
   trunk/mcs/class/corlib/System.IO/ChangeLog
   trunk/mcs/class/corlib/System.IO/FileStream.cs
   trunk/mcs/class/corlib/System.IO/MonoIO.cs
Log:
2005-04-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * FileStream.cs:
        * MonoIO.cs: remove dead code related to async IO.



Modified: trunk/mcs/class/corlib/System.IO/ChangeLog
===================================================================
--- trunk/mcs/class/corlib/System.IO/ChangeLog  2005-04-08 00:15:49 UTC (rev 
42666)
+++ trunk/mcs/class/corlib/System.IO/ChangeLog  2005-04-08 00:17:16 UTC (rev 
42667)
@@ -1,3 +1,8 @@
+2005-04-07 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * FileStream.cs:
+       * MonoIO.cs: remove dead code related to async IO.
+
 2005-03-24  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * Directory.cs: Added a Demand for Read/Write when creating a new 

Modified: trunk/mcs/class/corlib/System.IO/FileStream.cs
===================================================================
--- trunk/mcs/class/corlib/System.IO/FileStream.cs      2005-04-08 00:15:49 UTC 
(rev 42666)
+++ trunk/mcs/class/corlib/System.IO/FileStream.cs      2005-04-08 00:17:16 UTC 
(rev 42667)
@@ -82,6 +82,8 @@
                                this.canseek = true;
                        } else {
                                this.canseek = false;
+                               noBuffering = true;
+                               bufferSize = 0;
                        }
 
                        this.handle = handle;
@@ -90,9 +92,6 @@
                        this.async = isAsync;
                        this.anonymous = false;
 
-                       if (isAsync && MonoIO.SupportsAsync)
-                               ThreadPool.BindHandle (handle);
-
                        InitBuffer (bufferSize, noBuffering);
 
                        /* Can't set append mode */
@@ -198,8 +197,7 @@
 
                        MonoIOError error;
 
-                       bool openAsync = (isAsync && MonoIO.SupportsAsync);
-                       this.handle = MonoIO.Open (name, mode, access, share, 
openAsync, out error);
+                       this.handle = MonoIO.Open (name, mode, access, share, 
false, out error);
                        if (handle == MonoIO.InvalidHandle) {
                                // don't leak the path information for isolated 
storage
                                string fname = (anonymous) ? Path.GetFileName 
(name) : name;
@@ -215,8 +213,6 @@
                        if (MonoIO.GetFileType (handle, out error) == 
MonoFileType.Disk) {
                                this.canseek = true;
                                this.async = isAsync;
-                               if (openAsync)
-                                       ThreadPool.BindHandle (handle);
                        } else {
                                this.canseek = false;
                                this.async = false;
@@ -280,7 +276,7 @@
                                if (handle == MonoIO.InvalidHandle)
                                        throw new ObjectDisposedException 
("Stream has been closed");
 
-                               if (!canseek)
+                               if (!CanSeek)
                                        throw new NotSupportedException ("The 
stream does not support seeking");
 
                                // Buffered data might change the length of the 
stream
@@ -480,28 +476,8 @@
                        if (!async)
                                return base.BeginRead (buffer, offset, count, 
cback, state);
 
-                       if (!MonoIO.SupportsAsync) {
-                               ReadDelegate r = new ReadDelegate 
(ReadInternal);
-                               return r.BeginInvoke (buffer, offset, count, 
cback, state);                     
-                       }
-
-                       FileStreamAsyncResult result = new 
FileStreamAsyncResult (cback, state);
-                       result.Count = count;
-                       result.OriginalCount = count;
-                       int buffered = ReadSegment (buffer, offset, count);
-                       if (buffered >= count) {
-                               result.SetComplete (null, buffered, true);
-                               return result;
-                       }
-                       
-                       result.Buffer = buffer;
-                       result.Offset = offset + buffered;
-                       result.Count -= buffered;
-                       
-                       KeepReference (result);
-                       MonoIO.BeginRead (handle, result);
-
-                       return result;
+                       ReadDelegate r = new ReadDelegate (ReadInternal);
+                       return r.BeginInvoke (buffer, offset, count, cback, 
state);                     
                }
                
                public override int EndRead (IAsyncResult async_result)
@@ -512,35 +488,15 @@
                        if (!async)
                                return base.EndRead (async_result);
 
-                       if (!MonoIO.SupportsAsync) {
-                               AsyncResult ares = async_result as AsyncResult;
-                               if (ares == null)
-                                       throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
+                       AsyncResult ares = async_result as AsyncResult;
+                       if (ares == null)
+                               throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
 
-                               ReadDelegate r = ares.AsyncDelegate as 
ReadDelegate;
-                               if (r == null)
-                                       throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
-
-                               return r.EndInvoke (async_result);
-                       }
-
-                       FileStreamAsyncResult result = async_result as 
FileStreamAsyncResult;
-                       if (result == null || result.BytesRead == -1)
+                       ReadDelegate r = ares.AsyncDelegate as ReadDelegate;
+                       if (r == null)
                                throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
 
-                       RemoveReference (result);
-                       if (result.Done)
-                               throw new InvalidOperationException ("EndRead 
already called.");
-
-                       result.Done = true;
-                       if (!result.IsCompleted)
-                               result.AsyncWaitHandle.WaitOne ();
-
-                       if (result.Exception != null)
-                               throw result.Exception;
-
-                       buf_start += result.BytesRead;
-                       return result.OriginalCount - result.Count + 
result.BytesRead;
+                       return r.EndInvoke (async_result);
                }
 
                public override void Write (byte[] src, int src_offset, int 
count)
@@ -648,24 +604,8 @@
                                bytes = buffer;
                        }
 
-                       if (!MonoIO.SupportsAsync) {
-                               WriteDelegate w = new WriteDelegate 
(WriteInternal);
-                               return w.BeginInvoke (buffer, offset, count, 
cback, state);                     
-                       }
-
-                       if (buffered >= count) {
-                               result.SetComplete (null, buffered, true);
-                               return result;
-                       }
-                       
-                       result.Buffer = buffer;
-                       result.Offset = offset;
-                       result.Count = count;
-                       
-                       KeepReference (result);
-                       MonoIO.BeginWrite (handle, result);
-
-                       return result;
+                       WriteDelegate w = new WriteDelegate (WriteInternal);
+                       return w.BeginInvoke (buffer, offset, count, cback, 
state);                     
                }
                
                public override void EndWrite (IAsyncResult async_result)
@@ -678,36 +618,16 @@
                                return;
                        }
 
-                       if (!MonoIO.SupportsAsync) {
-                               AsyncResult ares = async_result as AsyncResult;
-                               if (ares == null)
-                                       throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
+                       AsyncResult ares = async_result as AsyncResult;
+                       if (ares == null)
+                               throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
 
-                               WriteDelegate w = ares.AsyncDelegate as 
WriteDelegate;
-                               if (w == null)
-                                       throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
-
-                               w.EndInvoke (async_result);
-                               return;
-                       }
-
-                       FileStreamAsyncResult result = async_result as 
FileStreamAsyncResult;
-                       if (result == null || result.BytesRead != -1)
+                       WriteDelegate w = ares.AsyncDelegate as WriteDelegate;
+                       if (w == null)
                                throw new ArgumentException ("Invalid 
IAsyncResult", "async_result");
 
-                       RemoveReference (result);
-                       if (result.Done)
-                               throw new InvalidOperationException ("EndWrite 
already called.");
-
-                       result.Done = true;
-                       if (!result.IsCompleted)
-                               result.AsyncWaitHandle.WaitOne ();
-
-                       if (result.Exception != null)
-                               throw result.Exception;
-
-                       buf_start += result.Count;
-                       buf_offset = buf_length = 0;
+                       w.EndInvoke (async_result);
+                       return;
                }
 
                public override long Seek (long offset, SeekOrigin origin)
@@ -1061,30 +981,9 @@
                        buf_dirty = false;
                }
 
-               static void KeepReference (object o)
-               {
-                       lock (typeof (FileStream)) {
-                               if (asyncObjects == null)
-                                       asyncObjects = new Hashtable ();
-
-                               asyncObjects [o] = o;
-                       }
-               }
-               
-               static void RemoveReference (object o)
-               {
-                       lock (typeof (FileStream)) {
-                               if (asyncObjects == null)
-                                       return;
-
-                               asyncObjects.Remove (o);
-                       }
-               }
-
                // fields
 
                internal const int DefaultBufferSize = 8192;
-               private static Hashtable asyncObjects;
 
                private FileAccess access;
                private bool owner;

Modified: trunk/mcs/class/corlib/System.IO/MonoIO.cs
===================================================================
--- trunk/mcs/class/corlib/System.IO/MonoIO.cs  2005-04-08 00:15:49 UTC (rev 
42666)
+++ trunk/mcs/class/corlib/System.IO/MonoIO.cs  2005-04-08 00:17:16 UTC (rev 
42667)
@@ -1,4 +1,3 @@
-//
 // System.IO.MonoIO.cs: static interface to native filesystem.
 //
 // Author:
@@ -45,10 +44,7 @@
                public static readonly IntPtr
                        InvalidHandle = (IntPtr)(-1L);
 
-               public static readonly bool SupportsAsync = GetSupportsAsync ();
-
                // error methods
-
                public static Exception GetException (MonoIOError error)
                {
                        return GetException (String.Empty, error);
@@ -155,10 +151,6 @@
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                public extern static MonoFileType GetFileType (IntPtr handle, 
out MonoIOError error);
 
-               // aio_* methods
-               [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               extern static bool GetSupportsAsync ();
-
                public static bool Exists (string path, out MonoIOError error)
                {
                        FileAttributes attrs = GetFileAttributes (path,
@@ -392,13 +384,6 @@
 
                [MethodImplAttribute (MethodImplOptions.InternalCall)]
                public extern static int GetTempPath(out string path);
-
-               [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               public extern static void BeginWrite (IntPtr 
handle,FileStreamAsyncResult ares);
-
-               [MethodImplAttribute (MethodImplOptions.InternalCall)]
-               public extern static void BeginRead (IntPtr handle, 
FileStreamAsyncResult ares);
-
        }
 }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to