--- a/Registry.st Wed Jan 08 20:07:09 1997 +0100
+++ b/Registry.st Wed Jan 08 20:42:17 1997 +0100
@@ -10,6 +10,8 @@
hereby transferred.
"
+'From Smalltalk/X, Version:3.1.3 on 8-jan-1997 at 14:05:07' !
+
Object subclass:#Registry
instanceVariableNames:'registeredObjects handleArray cleanState'
classVariableNames:''
@@ -96,7 +98,7 @@
wasBlocked := OperatingSystem blockInterrupts.
registeredObjects size == 0 "isNil" ifTrue:[
registeredObjects := WeakArray new:10.
- registeredObjects watcher:self.
+ registeredObjects addDependent:self.
handleArray := Array basicNew:10.
registeredObjects at:1 put:anObject.
handleArray at:1 put:aHandle.
@@ -148,7 +150,7 @@
newColl := WeakArray new:(size * 2).
newColl replaceFrom:1 to:size with:registeredObjects.
registeredObjects := newColl.
- registeredObjects watcher:self.
+ registeredObjects addDependent:self.
registeredObjects at:index put:anObject.
newPhantoms := Array basicNew:(size * 2).
@@ -159,6 +161,7 @@
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
"Modified: 22.6.1996 / 14:33:08 / cg"
+ "Modified: 7.1.1997 / 16:56:03 / stefan"
!
registerChange:anObject
@@ -204,34 +207,37 @@
!Registry methodsFor:'dispose handling'!
-informDispose
+informDispose:someHandle
+ someHandle disposed
+!
+
+update:something with:aParameter from:changedObject
"an instance has been destroyed - look which one it was"
- |phantom
- dstIdx "{ Class: SmallInteger }"
- sz "{ Class: SmallInteger }"
- tally "{ Class: SmallInteger }"
- newObjects newHandles|
+ something == #ElementExpired ifTrue:[
+ |phantom
+ dstIdx "{ Class: SmallInteger }"
+ sz "{ Class: SmallInteger }"
+ tally "{ Class: SmallInteger }"
+ newObjects newHandles|
- sz := handleArray size.
- tally := 0.
+ sz := handleArray size.
+ tally := 0.
- 1 to:sz do:[:index |
-"/ (registeredObjects at:index) isNil ifTrue:[
- (registeredObjects at:index) == 0 ifTrue:[
- registeredObjects at:index put:nil.
- phantom := handleArray at:index.
- phantom notNil ifTrue:[
- handleArray at:index put:nil.
- self informDispose:phantom
+ 1 to:sz do:[:index |
+ (registeredObjects at:index) == 0 ifTrue:[
+ registeredObjects at:index put:nil.
+ phantom := handleArray at:index.
+ phantom notNil ifTrue:[
+ handleArray at:index put:nil.
+ self informDispose:phantom
+ ]
+ ] ifFalse:[
+ tally := tally + 1
]
- ] ifFalse:[
- tally := tally + 1
- ]
- ].
+ ].
- sz > 50 ifTrue:[
- tally < (sz // 2) ifTrue:[
+ (sz > 50 and:[tally < (sz // 2)]) ifTrue:[
"/ shrink
newObjects := WeakArray new:(tally * 3 // 2).
newHandles := Array new:(newObjects size).
@@ -245,15 +251,22 @@
]
].
- newObjects watcher:self.
+ newObjects addDependent:self.
registeredObjects := newObjects.
handleArray := newHandles.
]
- ].
-!
+ ] ifFalse:[something == #earlyRestart ifTrue:[
+ handleArray notNil ifTrue:[
+ handleArray atAllPut:nil
+ ]
+ ]].
-informDispose:someHandle
- someHandle disposed
+"/ something == #returnFromSnapshot ifTrue:[
+"/ cleanState := true
+"/ ]
+
+ "Created: 15.6.1996 / 15:24:41 / cg"
+ "Modified: 8.1.1997 / 14:05:02 / stefan"
! !
!Registry methodsFor:'enumerating'!
@@ -270,24 +283,8 @@
]
! !
-!Registry methodsFor:'restart handling'!
-
-update:something with:aParameter from:changedObject
- something == #earlyRestart ifTrue:[
- handleArray notNil ifTrue:[
- handleArray atAllPut:nil
- ]
- ].
-
-"/ something == #returnFromSnapshot ifTrue:[
-"/ cleanState := true
-"/ ]
-
- "Created: 15.6.1996 / 15:24:41 / cg"
-! !
-
!Registry class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Registry.st,v 1.32 1996-11-11 11:36:28 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Registry.st,v 1.33 1997-01-08 19:42:13 stefan Exp $'
! !