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

commits at source.squeak.org commits at source.squeak.org
Tue Jun 15 18:40:55 UTC 2010


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

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

Name: Collections-ul.365
Author: ul
Time: 15 June 2010, 11:52:55.947 am
UUID: 333e9c8f-4030-fc4d-bb69-e8d8e175edc9
Ancestors: Collections-ul.362

- make sure that all executors are evaluated outside the critical section in WeakRegistry >> #finalizeValues to avoid deadlocks. To achieve this WeakRegistries collect the executors (the same way as it was in Collections-ul.294) and evaluate them at the end of #finalizeValues.

=============== Diff against Collections-ul.362 ===============

Item was changed:
  Collection subclass: #WeakRegistry
+ 	instanceVariableNames: 'valueDictionary accessLock executors'
- 	instanceVariableNames: 'valueDictionary accessLock'
  	classVariableNames: 'Default'
  	poolDictionaries: ''
  	category: 'Collections-Weak'!
  
  !WeakRegistry commentStamp: '<historical>' 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.
  
  See also:
  	Object executor
  	Object actAsExecutor
  	Object finalize
  !

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

Item was changed:
  ----- Method: WeakRegistry>>postCopy (in category 'copying') -----
  postCopy
  
  	self protected: [ "Uses the original accessLock"
  		accessLock := Semaphore forMutualExclusion.
  		valueDictionary := valueDictionary copy.
  		valueDictionary associationsDo: [ :each |
  			each value class == ObjectFinalizerCollection 
  				ifTrue: [ each value: each value copy ] ].
+ 		executors := executors copy.
  		self installFinalizer ]!

Item was changed:
  ----- Method: WeakRegistry>>finalizeValues (in category 'finalization') -----
  finalizeValues
  	"Some of our elements may have gone away. Look for those and activate the associated executors."
  	
+ 	| collectedExecutors |
+ 	self protected: [ 
+ 		valueDictionary finalizeValues.
+ 		collectedExecutors := executors.
+ 		executors := nil ].
+ 	collectedExecutors ifNotNil: [
+ 		collectedExecutors do: #finalize ]!
- 	self protected: [ valueDictionary finalizeValues ]!

Item was changed:
+ (PackageInfo named: 'Collections') postscript: 'WeakRegistry allSubInstancesDo: #installFinalizer'!
- (PackageInfo named: 'Collections') postscript: ''!




More information about the Squeak-dev mailing list