'From PharoCore1.1ALPHA of ''19 October 2009'' [Latest update: #11280] on 23 September 2010 at 8:35:07 pm'! !WeakFinalizationRegistry methodsFor: 'finalization' stamp: 'Igor.Stasenko 9/23/2010 19:54'! 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 9/23/2010 19:48'! installFinalizer " in Pharo, do nothing right now valueDictionary finalizer: #finalizeValues "! ! !WeakKeyDictionary methodsFor: 'accessing' stamp: 'Igor.Stasenko 9/23/2010 20:34'! slowSize "Careful!! Answer the maximum amount of elements in the receiver, not the exact amount" | count | count := 0. 1 to: array size do: [ :index | (array at: index) ifNotNil: [ :object | object key ifNotNil: [ count := count + 1 ] ] ]. ^count! ! !WeakKeyDictionary methodsFor: 'finalization' stamp: 'Igor.Stasenko 9/23/2010 20:26'! expiredValuesDo: aBlock "Clear all associations with nil keys" self allAssociationsDo:[:assoc | assoc key isNil ifTrue: [ aBlock value: assoc value. assoc expire. expired := expired + 1. tally := tally - 1. ]. ]. ! !