--- a/Stream.st Mon Oct 26 21:51:17 2009 +0000
+++ b/Stream.st Thu Nov 05 14:41:30 2009 +0000
@@ -560,16 +560,6 @@
with externalStreams."
!
-readWait
- ^ self "/ never have to wait
-!
-
-readWaitWithTimeoutMs:millis
- "Return true if a timeout occured (i.e. false, if data is available)."
-
- ^ false "/ never have to wait
-!
-
text
"switch to text mode.
Ignored here, but added to make internalStreams protocol compatible
@@ -577,14 +567,6 @@
"Modified: 15.5.1996 / 17:38:36 / cg"
"Created: 13.9.1996 / 18:33:26 / cg"
-!
-
-writeWait
- ^ self
-!
-
-writeWaitWithTimeoutMs:millis
- ^ false "/ never have to wait
! !
!Stream methodsFor:'misc functions'!
@@ -794,7 +776,7 @@
streams."
|n "{Class: SmallInteger }"
- dstIndex binary|
+ dstIndex binary b|
dstIndex := initialIndex.
n := 0.
@@ -805,10 +787,14 @@
^ n
].
binary ifTrue:[
- aCollection byteAt:dstIndex put:self nextByte.
+ b := self nextByte.
] ifFalse:[
- aCollection at:dstIndex put:self next.
+ b := self next.
+ b isInteger ifFalse:[
+ b := b asInteger
+ ].
].
+ aCollection byteAt:dstIndex put:b.
dstIndex := dstIndex + 1.
n := n + 1.
].
@@ -2535,6 +2521,95 @@
^ aVisitor visitStream:self with:aParameter
! !
+!Stream methodsFor:'waiting for I/O'!
+
+readWait
+ "suspend the current process, until the receiver
+ becomes ready for reading. If data is already available,
+ return immediate.
+ The other threads are not affected by the wait."
+
+ ^ self readWaitWithTimeoutMs:nil
+!
+
+readWaitTimeoutMs:timeout
+ "ST-80 compatibility"
+ ^ self readWaitWithTimeoutMs:timeout
+!
+
+readWaitWithTimeout:seconds
+ "suspend the current process, until the receiver
+ becomes ready for reading or a timeout (in seconds) expired.
+ If data is already available, return immediate.
+ With nil seconds, wait forever.
+ Return true if a timeout occured (i.e. false, if data is available).
+ The other threads are not affected by the wait."
+
+ |ms|
+
+ seconds notNil ifTrue:[
+ ms := seconds * 1000
+ ].
+ ^ self readWaitWithTimeoutMs:ms
+!
+
+readWaitWithTimeoutMs:millis
+ "suspend the current process, until the receiver
+ becomes ready for reading or a timeout (in milliseconds) expired.
+ If data is already available, return immediate.
+ With nil millis, wait forever.
+ Return true if a timeout occured (i.e. false, if data is available).
+ The other threads are not affected by the wait."
+
+ ^ false "/ never have to wait
+!
+
+readWriteWait
+ "suspend the current process, until the receiver
+ becomes ready for writing or reading.
+ Return immediate if the receiver is already ready.
+ The other threads are not affected by the wait."
+
+ self readWriteWaitWithTimeoutMs:nil
+!
+
+readWriteWaitWithTimeoutMs:millis
+ ^ false "/ never have to wait
+!
+
+writeWait
+ "suspend the current process, until the receiver
+ becomes ready for writing.
+ Return immediate if the receiver is already ready.
+ The other threads are not affected by the wait."
+
+ self writeWaitWithTimeoutMs:nil
+!
+
+writeWaitTimeoutMs:timeout
+ "ST-80 compatibility"
+ ^ self writeWaitWithTimeoutMs:timeout
+!
+
+writeWaitWithTimeout:timeout
+ "suspend the current process, until the receiver
+ becomes ready for writing or a timeout (in seconds) expired.
+ Return true if a timeout occured (i.e. false, if data is available).
+ Return immediate if the receiver is already ready.
+ The other threads are not affected by the wait."
+
+ |ms|
+
+ timeout notNil ifTrue:[
+ ms := timeout * 1000
+ ].
+ ^ self writeWaitWithTimeoutMs:ms
+!
+
+writeWaitWithTimeoutMs:millis
+ ^ false "/ never have to wait
+! !
+
!Stream methodsFor:'writing'!
commit
@@ -3008,12 +3083,13 @@
!Stream class methodsFor:'documentation'!
version
- ^ '$Id: Stream.st 10473 2009-10-24 15:48:19Z vranyj1 $'
+ ^ '$Id: Stream.st 10477 2009-11-05 14:41:30Z vranyj1 $'
!
version_CVS
- ^ '§Header: /cvs/stx/stx/libbasic/Stream.st,v 1.175 2009/10/05 09:21:03 cg Exp §'
+ ^ '$Id: Stream.st 10477 2009-11-05 14:41:30Z vranyj1 $'
! !
Stream initialize!
+