[squeak-dev] The Trunk: Collections-ul.398.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Oct 31 22:43:42 UTC 2010


Levente Uzonyi uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-ul.398.mcz

==================== Summary ====================

Name: Collections-ul.398
Author: ul
Time: 31 October 2010, 10:06:44.386 pm
UUID: a696b0b6-1bd2-dc45-9606-33aebcfdc74c
Ancestors: Collections-ar.397

- restore the behavior of the old finalization scheme

=============== Diff against Collections-ar.397 ===============

Item was changed:
  Collection subclass: #WeakRegistry
+ 	instanceVariableNames: 'list valueDictionary sema executors'
- 	instanceVariableNames: 'list valueDictionary sema'
  	classVariableNames: 'Default'
  	poolDictionaries: ''
  	category: 'Collections-Weak'!
  
  !WeakRegistry commentStamp: 'ul 9/26/2010 02:51' prior: 0!
  I am a registry for objects needing finalization. When an object is added the object as well as its executor is stored. When the object is garbage collected, the executor can take the appropriate action for any resources associated with the object.
  
  This kind of WeakRegistry is using a new VM feature, which allows a more robust finalization support. In contrast to the old implementation, it doesn't spend linear time checking which elements became garbage.
  
  See also:
  	Object executor
  	Object actAsExecutor
  	Object finalize!

Item was changed:
  ----- Method: WeakRegistry>>finalizeValues (in category 'finalization') -----
  finalizeValues
  	"Finalize any values, which happen to stocked in our list, due to some weak references become garbage"
  	
  	| finalizer |
- 
  	WeakFinalizationList hasNewFinalization ifFalse: [
+ 		self protected: [
+ 			valueDictionary finalizeValues.
+ 			finalizer := executors.
+ 			executors := nil ].
+ 		finalizer ifNotNil: [
+ 			finalizer do: [ :each | each finalizeValues ] ].
- 		self protected: [ valueDictionary finalizeValues ].
  		^ self ].
  
+ 	finalizer :=  self protected: [ list swapWithNil ].
- 	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 ].
- 		finalizer := next
- 	].
  !

Item was changed:
  ----- Method: WeakRegistry>>installFinalizer (in category 'initialize-release') -----
  installFinalizer
  
+ 	valueDictionary finalizer: [ :executor |
+ 		WeakFinalizationList hasNewFinalization 
+ 			ifTrue: [ executor finalizeValues ]
+ 			ifFalse: [ 
+ 				(executors ifNil: [ executors := OrderedCollection new ]) add: executor ] ]!
- 	valueDictionary finalizer: #finalizeValues!




More information about the Squeak-dev mailing list