[Pharo-project] Another finalization concern: error handling

Igor Stasenko siguctua at gmail.com
Mon Oct 11 08:07:49 EDT 2010


On 11 October 2010 14:40, Igor Stasenko <siguctua at gmail.com> wrote:
> Hello,
>
> here a situation, with which we can deal in more safer manner:
>
> Suppose you have a weak registry, populated by different objects and
> their executors.
>
> Now, when some of them died, a weak registry performs finalization.
>
> The potential danger is , that if there's an error triggered by some
> executor(s),
> then rest of executors will have no chance to run and will be
> forgotten, causing memory leakage.
>
> What you think, should we handle this more graciously?
>
> (Consider a following meta-code)
>
> WeakRegistry>>finalizeValues
> | executors |
>  executors := self gatherExecutorsToRun.
>
>  executors do: [:ex |
>     [ ex finalize ] fork.
>  ].
>

oh, and this gets even more complicated, if we keep supporting
multiple finalizers per single object. :)

executors do: [:ex |
  ex hasMultipleExecutors ifTrue: [ ex do: [ :eex |   [ eex finalize ] fork ] ]
  ifFalse: [  [ ex finalize ] fork ].



> in this way, if any executor's #finalize causing error, it won't
> interfere with other executors, and they will accomplish their task
> normally.
> Of course, i'm not saying that we should use #fork for this, because
> it is costly. Similar could be done w/o forking.
> I just wanted to show a simplest code with which we could achieve a
> more gracious error handling.
>
> P.S. of course, in a first place it would be good to make sure that we
> writing executors, which can't cause an error during finalization.
> But bad things happen, and we should make sure that rest of system
> won't be put on its knees because of some stupid bug in a single
> #finalize.
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>



-- 
Best regards,
Igor Stasenko AKA sig.




More information about the Pharo-dev mailing list