'From Pharo1.2a of ''11 June 2010'' [Latest update: #12159] on 1 October 2010 at 6:03:55 pm'! !WeakFinalizationRegistry methodsFor: 'finalization' stamp: 'Igor.Stasenko 10/1/2010 18:01'! finalizeValues "Finalize any values, which happen to stocked in our list, due to some weak references become garbage" | finalizer | " Do the old way, if VM don't supports us" WeakFinalizationList hasNewFinalization ifFalse: [ self protected: [ valueDictionary expiredValuesDo: [:finItem | finItem finalizeValues ]. " Not yet in Pharo --- valueDictionary finalizeValues " ]. ^ self ]. self protected: [ finalizer := list swapWithNil ]. "We don't need to protect a following loop from concurrent access, because at the moment we're finalizing values, only we can access this list of finalizers, because valueDictionary already see them as an unused slots, because they're associated with key == nil" [ finalizer notNil ] whileTrue: [ | next | next := finalizer next. finalizer finalizeValues. finalizer := next ]. ! ! !WeakFinalizationRegistry methodsFor: 'initialize-release' stamp: 'Igor.Stasenko 10/1/2010 18:01'! installFinalizer " do nothing, pharo does not supports it right now valueDictionary finalizer: #finalizeValues "! ! !WeakFinalizationRegistry class methodsFor: 'migrating registry' stamp: 'Igor.Stasenko 10/1/2010 18:03'! migrateOldRegistries Smalltalk at: #WeakFinalizationRegistry ifAbsent: [ ^ self "already done" ]. Smalltalk recreateSpecialObjectsArray. WeakArray restartFinalizationProcess. Smalltalk garbageCollect; garbageCollect. "leave no chance to interrupt migration" Compiler evaluate: ' [ | old new oldClass newClass | old := OrderedCollection new. new := OrderedCollection new. WeakRegistry allInstancesDo: [:registry | | newr | old add: registry. newr := WeakFinalizationRegistry basicNew initialize. registry migrateTo: newr. new add: newr ]. old asArray elementsForwardIdentityTo: new asArray. oldClass := WeakRegistry. newClass := WeakFinalizationRegistry. Smalltalk forgetClass: WeakFinalizationRegistry logged: false. newClass superclass removeSubclass: newClass. newClass setName: #WeakRegistry. oldClass becomeForward: newClass. ] forkAt: Processor highestPriority. '. ! !