diff -r a27a279701f8 -r 6526dde5f3ac Registry.st --- a/Registry.st Fri Jul 16 11:39:45 1993 +0200 +++ b/Registry.st Mon Oct 04 11:32:33 1993 +0100 @@ -56,8 +56,8 @@ 1 to:phantoms size do:[:index | (registeredObjects at:index) isNil ifTrue:[ - (phantoms at:index) notNil ifTrue:[ - phantom := phantoms at:index. + phantom := phantoms at:index. + phantom notNil ifTrue:[ phantoms at:index put:nil. phantom disposed ] @@ -100,9 +100,11 @@ register:anObject "register anObject, so that a copy of it gets the disposed message - when anObject dies (somewhere in the future)" + when anObject dies (some time in the future)" - |phantom newColl count p index| + |phantom newColl newPhantoms + count "{ Class: SmallInteger }" + p index| phantom := anObject shallowCopy. @@ -110,14 +112,17 @@ registeredObjects := ShadowArray new:10. registeredObjects watcher:self. registeredObjects at:1 put:anObject. - phantoms := VariableArray with:phantom. + phantoms := Array new:10. + phantoms at:1 put:phantom. + ObjectMemory addDependent:self. ^ self ]. index := registeredObjects identityIndexOf:anObject ifAbsent:[0]. index ~~ 0 ifTrue:[ - self error:'bad register'. + "already registered" phantoms at:index put:phantom. + self error:'object is already registered'. ^ self ]. @@ -126,16 +131,15 @@ 1 to:count do:[:index | (registeredObjects at:index) isNil ifTrue:[ "is there a leftover ?" - (phantoms at:index) notNil ifTrue:[ - p := phantoms at:index. + p := phantoms at:index. + p notNil ifTrue:[ phantoms at:index put:nil. - p disposed + p disposed. + p := nil. ]. - (phantoms at:index) isNil ifTrue:[ - registeredObjects at:index put:anObject. - phantoms at:index put:phantom. - ^ self - ] + registeredObjects at:index put:anObject. + phantoms at:index put:phantom. + ^ self ] ]. @@ -145,9 +149,12 @@ newColl replaceFrom:1 to:count with:registeredObjects. registeredObjects := newColl. registeredObjects watcher:self. + registeredObjects at:(count + 1) put:anObject. - registeredObjects at:(count + 1) put:anObject. - phantoms add:phantom + newPhantoms := Array new:(count * 2). + newPhantoms replaceFrom:1 to:count with:phantoms. + phantoms := newPhantoms. + phantoms at:(count + 1) put:phantom. ! unregister:anObject @@ -163,3 +170,13 @@ registeredObjects at:index put:nil ] ! ! + +!Registry methodsFor:'restart handling'! + +update:aParameter + aParameter == #restarted ifTrue:[ + phantoms notNil ifTrue:[ + phantoms atAllPut:nil + ] + ] +! !