[squeak-dev] Weak collection changes

Levente Uzonyi leves at elte.hu
Thu Feb 4 02:06:03 UTC 2010


Hi,


I uploaded a new version of the Collections package to the Inbox 
(Collections-ul.295) for reviewing.
If contains the following changes:

WeakSet:
- new grow strategy implemented via #growSize (it can actually shrink if
   too many elements are garbageCollected)
- semantic change: #slowSize doesn't change (decrease) the value of tally
   so it doesn't supress growing
- #fixCollisionsFrom: recycles free slots

WeakKeyDictionary:
- new finalization strategy: push model instead of pull (via finalizer)
- new instance variable named finalizer. If it's value is not nil, then it
   will be evaluated with the finalized associations' value
- #fixCollisionsFrom: finalizes values and recycles free slots, instead of
   rehashing (this boosts performance)
- new method: #slowSize which counts only those associations which have a
   not nil key
- new grow stategy (same as WeakSet's)
- #finalizeValues: is deprecated
- #noCheckNoGrowFillFrom: (used by #grow and #rehash) finalizes values via
   finalizer if it's not nil
- cosmetic changes

WeakRegistry:
- new instance variable named objectsToFinalize, it's value is nil or
   an OrderedCollection which collects the executors of garbage collected
   objects. Access to objectsToFinalize always protected.
- new finalization strategy uses the finalizing capability of
   WeakKeyDictionary. WeakRegistry adds a finalizer block to its
   WeakKeyDictionary which adds the received object to objectsToFinalize
- #finalizeValues, #remove:ifAbsent: simplified
- #finalizeValues has O(size) runtime worst case
- cosmetic changes

+a postscript for installing the finalizer blocks

Passes all tests in WeakRegistryTest.


It can be loaded to clean Trunk images (tested in 8972), but it has to 
be splitted (or tweaked) if we decide to add these to the trunk. Also 
further minor changes are on the way.


Cheers,
Levente



More information about the Squeak-dev mailing list