2009/10/26 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
Philippe, Stef,
That's fine for Seaside, but what about other users of weak collections? Â I think I have found the weakness (pun intended) in Squeak/Pharo: weaklings do only half of what they should do. Â They (correctly) do not prevent garbage collection of the objects they reference, but they apparently fail to clean up after these objects have been finalized.
In Dolphin, the following returns an empty array:
| map | map := WeakLookupTable new         at:2 put:String new;         yourself. MemoryManager current collectGarbage. map keys asArray.
Pharo is content to answer nil from #at:put: but still keep the key:
| map | map := WeakValueDictionary new         at:2 put:String new;         yourself. 5 timesRepeat:[ Smalltalk garbageCollect. ]. map keys asArray.
and why the key should go away? I think that this is an implementation nuance, but not bug or missing feature. No-one would expect from dictionary keys to automatically mutate depending on the state of the associated values. If you want such behavior, why not implement own WeakLookupTable ?
Gary reported a lack of thread saftey in the weak collections almost two years ago. Â See Mantis #6955.
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Philippe Marschall Sent: Sunday, October 25, 2009 9:44 AM To: pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Thread-safe collections
Igor Stasenko wrote:
2009/10/23 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
Hello all,
I just looked around for thread-safe collections, and found nothing that looks like a shared dictionary. Â The squeak-dev archives contain the obligatory newbie posts (wanting all collections to be thread safe) and the expected replies, some of which are overly dismissive of the idea. Â Something that protects things like #at:ifAbsentPut: and friends is _really_ useful. Â Am I missing an existing implementation?
Imo, there's only one shared collection which is useful - shared queue. :)
Yeah, sure. Where again do I store my Seaside sessions? Oh, it's no problem, because we use only one worker thread and process requests on after another. Geez, problem solved.
Cheers Philippe
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.