[Gd-chatter] r11169 - trunk/fundev/sources/io/streams

hannes at gwydiondylan.org hannes at gwydiondylan.org
Sun Feb 11 19:26:45 CET 2007


Author: hannes
Date: Sun Feb 11 19:26:42 2007
New Revision: 11169

Modified:
   trunk/fundev/sources/io/streams/buffered-stream.dylan
   trunk/fundev/sources/io/streams/stream.dylan
Log:
Bug: 7183
provide init-keyword for <stream> to overwrite lock


Modified: trunk/fundev/sources/io/streams/buffered-stream.dylan
==============================================================================
--- trunk/fundev/sources/io/streams/buffered-stream.dylan	(original)
+++ trunk/fundev/sources/io/streams/buffered-stream.dylan	Sun Feb 11 19:26:42 2007
@@ -173,7 +173,6 @@
 define inline function get-output-buffer
     (stream :: <buffered-stream>, #key bytes = 1)
  => (buffer :: false-or(<buffer>))
-  with-stream-locked(stream)
   let sb = stream-output-buffer(stream);
   if (sb)
     let sb :: <buffer> = sb; // HACK: TYPE ONLY
@@ -185,7 +184,6 @@
   else
     do-get-output-buffer(stream, bytes: bytes)
   end
-  end
 end function get-output-buffer;
 
 // No default method for this

Modified: trunk/fundev/sources/io/streams/stream.dylan
==============================================================================
--- trunk/fundev/sources/io/streams/stream.dylan	(original)
+++ trunk/fundev/sources/io/streams/stream.dylan	Sun Feb 11 19:26:42 2007
@@ -24,7 +24,8 @@
     init-keyword: element-type:;
   slot private-stream-direction-value :: <integer>; //  = $input,
    //   init-keyword: direction:;
-  constant slot private-stream-lock-value :: <lock> = make(<recursive-lock>);
+  slot private-stream-lock-value :: false-or(<lock>) = make(<recursive-lock>),
+    init-keyword: stream-lock:;
 end class <basic-stream>;
 
 define method initialize
@@ -128,15 +129,21 @@
 end function;
 
 define open generic stream-lock
-    (stream :: <basic-stream>) => (lock);
+    (stream :: <basic-stream>) => (lock :: false-or(<lock>));
 
 define sealed generic stream-lock-setter 
-    (value, the-stream :: <basic-stream>) => (result>);
+    (value, the-stream :: <basic-stream>) => (result :: false-or(<lock>));
 
-define method stream-lock (the-stream :: <basic-stream>) => (result>)
+define method stream-lock
+    (the-stream :: <basic-stream>) => (result :: false-or(<lock>))
   the-stream.private-stream-lock-value
 end method stream-lock;
 
+define method stream-lock-setter
+    (value :: false-or(<lock>), the-stream :: <basic-stream>)
+ => (result :: false-or(<lock>))
+  the-stream.private-stream-lock-value := value;
+end;
 
 /// Stream query functions, common to all streams
 
@@ -307,21 +314,25 @@
 define method stream-locked?
     (stream :: <stream>) => (locked? :: <boolean>)
   stream-lock(stream)
-    & stream-lock(stream).owned?
+   & stream-lock(stream).owned?
 end method stream-locked?;
 
 define open generic lock-stream
     (stream :: <stream>) => ();
 
 define method lock-stream (stream :: <stream>) => ()
-  wait-for(stream-lock(stream));
+  if (stream-lock(stream))
+    wait-for(stream-lock(stream));
+  end
 end method lock-stream;
 
 define open generic unlock-stream
     (stream :: <stream>) => ();
 
 define method unlock-stream (stream :: <stream>) => ()
-  release(stream-lock(stream))
+  if (stream-lock(stream))
+    release(stream-lock(stream))
+  end
 end method unlock-stream;
 
 define macro with-stream-locked



More information about the chatter mailing list