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

Levente Uzonyi leves at elte.hu
Mon Oct 11 03:03:34 UTC 2010


On Mon, 11 Oct 2010, Igor Stasenko wrote:

> 2010/10/11 Levente Uzonyi <leves at elte.hu>:
>>
>> The conclusion is that there is code out there which relies on having
>> multiple finalizers per object. Even if that code uses a private
>> WeakRegistry, one finalizer is not enough.
>>
>
> no, because if you own your private registry, you can do things like:
>
> oldExecutor := registry remove: object.
> oldExecutor ifNil:  [ .... registry add: object executor: newExecutor]
> ifNotNil: [ registry add: object executor: (oldExecutor addExecutor:
> newExecutor) ].
>
> (where addExecutor: should answer an executor, which is a combination
> old and new one).
>
> so, there will be no 'multiple executors' seen by weak registry. Just one.

How would it be different from the current implementation?

>
>> Btw, what's your problem with multiple finalizers per object?
>>
>
> the problem is , that in its current form it is a best way to shoot
> yourself into own foot.
> (read again, why #remove: in general case are not safely applicable
> with multiple finalizers/executors)).

IMHO #remove: is totally safe if you know what you're doing. You could say 
that it's not, because someone can remove your executor from the default 
WeakRegistry (WeakRegistry default), but this situation wouldn't change if 
there were only a single executor per object.


Levente

>
>
>> Levente
>>
>
>
>
> -- 
> Best regards,
> Igor Stasenko AKA sig.
>
>



More information about the Squeak-dev mailing list