Use #finalize instead of #disposed
authorStefan Vogel <sv@exept.de>
Mon, 04 Mar 2002 15:21:43 +0100
changeset 6439 0f841258ec4a
parent 6438 9df1edfc0b54
child 6440 eb9cdc352a7c
Use #finalize instead of #disposed
OSFileHandle.st
OSHandle.st
Object.st
PipeStream.st
Registry.st
--- a/OSFileHandle.st	Mon Mar 04 10:23:20 2002 +0100
+++ b/OSFileHandle.st	Mon Mar 04 15:21:43 2002 +0100
@@ -61,11 +61,10 @@
 
 !OSFileHandle methodsFor:'finalization'!
 
-disposed
+finalize
     "a filedescriptor was garbage collected - close the underlying file"
 
     self closeFile
-
 ! !
 
 !OSFileHandle methodsFor:'input/output'!
@@ -107,6 +106,6 @@
 !OSFileHandle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/OSFileHandle.st,v 1.4 2001-12-11 16:04:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/OSFileHandle.st,v 1.5 2002-03-04 14:21:43 stefan Exp $'
 ! !
 OSFileHandle initialize!
--- a/OSHandle.st	Mon Mar 04 10:23:20 2002 +0100
+++ b/OSHandle.st	Mon Mar 04 15:21:43 2002 +0100
@@ -54,12 +54,12 @@
 
 !OSHandle methodsFor:'finalization'!
 
-disposed
+finalize
     self subclassResponsibility
 ! !
 
 !OSHandle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/OSHandle.st,v 1.7 2001-12-11 17:47:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/OSHandle.st,v 1.8 2002-03-04 14:21:30 stefan Exp $'
 ! !
--- a/Object.st	Mon Mar 04 10:23:20 2002 +0100
+++ b/Object.st	Mon Mar 04 15:21:43 2002 +0100
@@ -2757,14 +2757,14 @@
 !
 
 shallowCopyForFinalization
-    "this is used to aquire a copy to be used for finalization -
+    "OBSOLETE INTERFACE: use #executor.
+     This is used to aquire a copy to be used for finalization -
      (the copy will get a dispose-notification; see the documentation in the Registry class)
      This method can be redefined for more efficient copying - especially for large objects."
 
-    "/ going to be obsoleted by executor
+    <resource: #obsolete>
+
     ^ self shallowCopy
-
-    "Modified: / 5.8.1999 / 14:07:16 / cg"
 !
 
 simpleDeepCopy
@@ -4024,31 +4024,36 @@
 !Object methodsFor:'finalization'!
 
 disposed
-    "this is invoked for objects which have been registered
+    "OBSOLETE INTERFACE: use #finalize
+     this is invoked for objects which have been registered
      in a Registry, when the original object dies.
      Subclasses may redefine this method"
 
+    <resource: #obsolete>
+
     ^ self
-
-    "Created: / 4.3.1998 / 10:40:30 / stefan"
 !
 
 executor
-    "for VW & Squeak compatibility.
-     Return the object which does the finalization for me."
+    "Return the object which does the finalization for me.
+     This interface is also VW & Sqeak compatible,"
+
+    "for now, send #shallowCopyForFinalization, to be compatible with
+     classes designed for old ST/X versions"
 
     ^ self shallowCopyForFinalization
-
-    "Created: / 5.8.1999 / 14:06:19 / cg"
 !
 
 finalize
-    "For ST80 compatibility; ST/X uses #disposed when registered
-     objects are finalized. This may change."
-
-    ^ self
-
-    "Created: / 4.3.1998 / 10:40:30 / stefan"
+    "this is invoked for executor objects which have been registered
+     in a Registry, when the original object dies.
+     Subclasses may redefine this method
+     This interface is also VW-compatible"
+
+    "send #disposed for compatibility with existing classes that still
+     implement the obsolete #disposed message"
+
+    ^ self disposed
 !
 
 reRegisterForFinalization
@@ -8657,6 +8662,6 @@
 !Object class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.395 2002-02-26 13:01:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Object.st,v 1.396 2002-03-04 14:19:59 stefan Exp $'
 ! !
 Object initialize!
--- a/PipeStream.st	Mon Mar 04 10:23:20 2002 +0100
+++ b/PipeStream.st	Mon Mar 04 15:21:43 2002 +0100
@@ -385,7 +385,7 @@
 
 !PipeStream methodsFor:'finalization'!
 
-disposed
+finalize
     "redefined to avoid blocking in close."
 
     self shutDown
@@ -709,11 +709,12 @@
 
     "Modified: / 23.4.1996 / 17:05:59 / stefan"
     "Modified: / 28.1.1998 / 14:47:34 / md"
-    "Created: / 19.5.1999 / 12:28:54 / cg"! !
+    "Created: / 19.5.1999 / 12:28:54 / cg"
+! !
 
 !PipeStream class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.90 2001-12-10 16:27:44 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/PipeStream.st,v 1.91 2002-03-04 14:20:44 stefan Exp $'
 ! !
 PipeStream initialize!
--- a/Registry.st	Mon Mar 04 10:23:20 2002 +0100
+++ b/Registry.st	Mon Mar 04 15:21:43 2002 +0100
@@ -39,9 +39,9 @@
 "
     Registries provide an easy interface to using WeakArrays. 
     A class, which wants to be informed of instance-death, can put a created object
-    into a registry. The registry will create a (shallow-)copy of the object, and
-    watch out for death of the original object. When it dies, the copy will
-    be sent a #disposed-message.
+    into a registry. The registry will create an executor, which is a (shallow-)copy 
+    of the object, and watch out for death of the original object. When it dies, 
+    the executor will be sent a #finalize message.
     The trick with the shallow copy is especially nice, you can think of it as
     being the original object which died.
 
@@ -52,12 +52,12 @@
     Of course, you too can use it to do whatever you need to do in case of the
     death of an object.
 
-    Registries use #shallowCopyForFinalization to aquire the copy of the original,
+    Registries use #executor to aquire the copy of the original,
     this can be redefined in registered classes for faster copying 
     (typically, not all internal state but only some device handles are needed for 
     finalization). I if the to-be-registered object is large, this method may also
     return a stub (placeHolder) object. (i.e. there is no need for the copy to be
-    of the same class as the original, as long as it implements disposed and frees
+    of the same class as the original, as long as it implements #finalize and frees
     the relevant OS resources ...)
     Example uses are found in Form, Color, ExternalStream and Font
 
@@ -85,10 +85,10 @@
 !Registry methodsFor:'dispose handling'!
 
 informDispose:someHandle
-    "send a dispose message - this is sent to the phantom,
+    "send a dispose message - this is sent to the executor,
      since the original is already gone"
 
-    someHandle disposed
+    someHandle finalize
 
     "Modified: 16.1.1997 / 17:23:46 / cg"
 !
@@ -96,7 +96,7 @@
 update:something with:aParameter from:changedObject
     "an instance has been destroyed - look which one it was"
 
-    |phantom
+    |executor
      index  "{ Class: SmallInteger }"
      sz     "{ Class: SmallInteger }"
      o myHandleArray wasBlocked|
@@ -113,17 +113,17 @@
                 o := registeredObjects at:index.
                 o notNil ifTrue:[
                     o == 0 ifTrue:[
-                        phantom := myHandleArray at:index.
+                        executor := myHandleArray at:index.
                         registeredObjects at:index put:nil.
                         tally := tally - 1.
-                        phantom notNil ifTrue:[
+                        executor notNil ifTrue:[
                             myHandleArray at:index put:nil.
 
                             "/
                             "/ allow interrupts for a while ...
                             "/
                             wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
-                            self informDispose:phantom.
+                            self informDispose:executor.
                             OperatingSystem blockInterrupts.
 
                             "/
@@ -178,7 +178,7 @@
 repairTally
     |sz          "{ Class: SmallInteger }"
      cnt         "{ Class: SmallInteger }"
-     phantom wasBlocked|
+     executor wasBlocked|
 
     wasBlocked := OperatingSystem blockInterrupts.
 
@@ -188,9 +188,9 @@
     cnt := 0.
 
     1 to:sz do:[:index |
-        ((phantom := registeredObjects at:index) notNil 
-        and:[phantom ~~ 0]) ifTrue:[
-            indexTable at:phantom put:index.
+        ((executor := registeredObjects at:index) notNil 
+        and:[executor ~~ 0]) ifTrue:[
+            indexTable at:executor put:index.
             cnt := cnt + 1.
         ] ifFalse:[
             handleArray at:index put:nil.
@@ -208,7 +208,7 @@
      dstIndex    "{ Class: SmallInteger }"
      realNewSize "{ Class: SmallInteger }"
      newObjects newHandles wasBlocked 
-     phantom|
+     executor|
 
     sz := registeredObjects size.
 
@@ -225,16 +225,16 @@
 
         dstIndex := 1.
         1 to:sz do:[:index |
-            (phantom := registeredObjects at:index) notNil ifTrue:[
+            (executor := registeredObjects at:index) notNil ifTrue:[
                 dstIndex > realNewSize ifTrue:[
                     'Registry [error]: size given is too small in resize' errorPrintCR.
                     self repairTally.
                     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
                     ^ self
                 ].
-                newObjects at:dstIndex put:phantom.
+                newObjects at:dstIndex put:executor.
                 newHandles at:dstIndex put:(handleArray at:index).
-                indexTable at:phantom put:dstIndex.
+                indexTable at:executor put:dstIndex.
 
                 dstIndex := dstIndex + 1
             ]
@@ -351,17 +351,17 @@
         ].
 
         "/ mhmh - a registeredObject vanished, but its
-        "/ phantom is still there ...
+        "/ executor is still there ...
 
         "/
         "/ this may happen, if the registries dispose handling is 
         "/ currently being executed by a lower priority process,
         "/ and the registeredObject has already been nilled,
-        "/ but the phantom is being notified (in the other process).
+        "/ but the executor is being notified (in the other process).
 
-"/        'Registry [info]: leftOver phantom: ' infoPrint. p infoPrintCR.
+"/        'Registry [info]: leftOver executor: ' infoPrint. p infoPrintCR.
 
-"/        "tell the phantom"
+"/        "tell the executor"
 "/        handleArray at:index put:nil.
 "/        tally := tally - 1.
 "/        self informDispose:p.
@@ -397,7 +397,7 @@
 !
 
 registerChange:anObject
-    "a registered object has changed, create a new phantom"
+    "a registered object has changed, create a new executor"
 
     |index wasBlocked copy|
 
@@ -420,7 +420,7 @@
 !
 
 unregister:anObject
-    "remove registration of anObject, without telling the phantom;
+    "remove registration of anObject, without telling the executor;
      should be sent, if we are no more interested in destruction of
      anObject (i.e. it no longer holds external resources)."
 
@@ -473,5 +473,5 @@
 !Registry class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Registry.st,v 1.55 2002-02-26 13:00:48 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Registry.st,v 1.56 2002-03-04 14:20:19 stefan Exp $'
 ! !