[squeak-dev] Re: WeakRegistry>>remove: - when you'll be in trouble

Igor Stasenko siguctua at gmail.com
Sun Oct 10 13:20:31 UTC 2010


Moreover, i personally don't understand, why WeakRegistry have to be a
subclass of Collection.

What
registry copy reject, select etc
means to weak registry?

My gut feeling that this is conceptually wrong.
One should not use any kind of copying on weak registry.

I think, that more intention revealing , one should send:
registry discardFinalization: anObject
instead of:
registry remove: anObject

On 10 October 2010 15:59, Igor Stasenko <siguctua at gmail.com> wrote:
> A current implementation of this method
>
> remove: oldObject ifAbsent: exceptionBlock
>        "Remove oldObject as one of the receiver's elements."
>
>        oldObject ifNil: [ ^nil ].
>        ^(self protected: [ valueDictionary removeKey: oldObject ifAbsent: nil ])
>                ifNil: [ exceptionBlock value ]
>
> simply removes a previously registered object from registry and voila.
>
> Now lets get back to our discussion about multiple finalizers per
> object and using them in weak subscriptions etc.
>
> Suppose i am added a socket to weak registry,
> and suppose i am added a weak subscription to it.
>
> Now, if i do 'socket close' , it tells weak registry to remove it from list.
> And what we'll have:
>  - socket handle is closed
>  - socket is wiped from weak registry
>  - but weak subscription still listed somewhere in a list of subscriptions
>
>
> My suggestion is, that upon #remove:,
> a weak registry should notify all executors that object of interest
> are no longer takes part in finalization scheme,
> so they should not count on receiving #finalize eventually.
>
> In other words:
>
> remove: oldObject ifAbsent: exceptionBlock
>        "Remove oldObject as one of the receiver's elements."
>
>        oldObject ifNil: [ ^nil ].
>        ^(self protected: [ | executor |
>             executor := valueDictionary removeKey: oldObject ifAbsent: nil.
>             executor discardFinalization.
>         ])
>        ifNil: [ exceptionBlock value ]
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list