ExternalStream.st
changeset 22694 5d16e0dd2bdc
parent 22683 f46cf6f2fe68
child 22697 e840d7085b3e
--- a/ExternalStream.st	Mon Apr 23 17:15:46 2018 +0200
+++ b/ExternalStream.st	Mon Apr 23 18:55:34 2018 +0200
@@ -2622,12 +2622,26 @@
 
 !ExternalStream methodsFor:'finalization'!
 
+beExecutor
+    "mark myself as being an executor for finalization.
+     We mis-use the mode symbol for this."
+
+    mode := #executor.
+
+    "Created: / 23-04-2018 / 18:17:01 / stefan"
+!
+
 executor
     "return a copy for finalization-registration;
      since all we need at finalization time is the fileDescriptor,
      a cheaper copy is possible."
 
-    ^ self class basicNew setAccessor:handleType to:handle
+    ^ self class basicNew
+                    beExecutor;
+                    setAccessor:handleType to:handle;
+                    yourself.
+
+    "Modified: / 23-04-2018 / 18:34:38 / stefan"
 !
 
 finalize
@@ -5714,6 +5728,14 @@
     ^ OperatingSystem isBlockingOn:fd
 !
 
+isExecutor
+    "am I an executor and no real stream object?"
+
+    ^ mode == #executor.
+
+    "Created: / 23-04-2018 / 18:17:40 / stefan"
+!
+
 isExternalStream
     "return true, if the receiver is some kind of externalStream;
      true is returned here - the method redefined from Object."
@@ -5724,7 +5746,11 @@
 isOpen
     "return true, if this stream is open"
 
-    ^ handle notNil
+    "executors are only used to finalize - they are not really open and are closed with #closeFile,
+     which does not check for #isOpen"
+    ^ handle notNil and:[self isExecutor not]
+
+    "Modified: / 23-04-2018 / 18:28:07 / stefan"
 !
 
 isReadable