[squeak-dev] Re: Silly question: How do I make a cache registry
leves at elte.hu
Tue Mar 15 17:11:29 UTC 2011
On Tue, 15 Mar 2011, Marcel Taeumel wrote:
> Use this:
> WeakArray addWeakDependent: myDict.
> There is a process called "WeakArray finalization process" which calls
> #finalizeValues on its dependents frequently. For WeakValueDictionary that
> would be a removal of the key that got "nil".
This is a pretty bad idea, because sooner or later the dictionary will be
invalid, because of concurrent access to it (your process and the
Also WeakValueDictionary doesn't implement #finalizeValues.
The right solution is a WeakValueDictionary which is protected from
concurrent access + registering each stored object in a WeakRegistry.
I made a wrapper object based on Igor's Stratified proxies
(http://code.google.com/p/pharo/issues/detail?id=3648 ) which encapsulates
another object and ensures that only one process can access the wrapped
object at a time. This could help with the first part.
> View this message in context: http://forum.world.st/Silly-question-How-do-I-make-a-cache-registry-tp3357027p3357049.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
More information about the Squeak-dev