--- a/ExternalStream.st Wed Nov 25 19:43:30 2015 +0100
+++ b/ExternalStream.st Wed Nov 25 19:44:31 2015 +0100
@@ -5613,6 +5613,44 @@
^ hasTimedout
!
+writeExceptionWaitWithTimeoutMs:timeout
+ "suspend the current process, until the receiver
+ becomes ready for reading or writing or a timeout (in milliseconds) 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."
+
+ |fd sema hasTimedout wasBlocked|
+
+ handle isNil ifTrue:[
+ ^ self errorNotOpen
+ ].
+
+ fd := self fileDescriptor.
+ (OperatingSystem writeExceptionCheck:fd) ifTrue:[^ false].
+
+ wasBlocked := OperatingSystem blockInterrupts.
+ sema := Semaphore new name:'writeExceptionWait'.
+ [
+ timeout notNil ifTrue:[
+ Processor signal:sema afterMilliseconds:timeout
+ ].
+ Processor signal:sema onOutput:fd.
+ Processor signal:sema onException:fd.
+ Processor activeProcess state:#ioWait.
+ sema wait.
+ hasTimedout := timeout notNil and:[(OperatingSystem readWriteCheck:fd) not].
+ ] ifCurtailed:[
+ Processor disableSemaphore:sema.
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ ].
+ timeout notNil ifTrue:[
+ Processor disableSemaphore:sema.
+ ].
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ ^ hasTimedout
+!
+
writeWaitWithTimeoutMs:timeout
"suspend the current process, until the receiver
becomes ready for writing or a timeout (in milliseconds) expired.