[squeak-dev] Re: Improving a Process termination procedure

Igor Stasenko siguctua at gmail.com
Fri May 1 16:54:36 UTC 2009


2009/5/1 Julian Fitzell <jfitzell at gmail.com>:
> On Fri, May 1, 2009 at 3:11 AM, Igor Stasenko <siguctua at gmail.com> wrote:
>> Another improvement would be to marry the process termination with
>> exception handling,
>> and nicely signal ProcessTerminatedException.
>
> Which is pretty much what VW does, I think.
>
>> This offers many practical benefits, since then we could write:
>>
>> [ ... ] on: ProcessTerminatedException do: [:ex |
>>   "oh man we're been terminated"
>> ].
>>
>> But i'm not expert in exception handling.
>> Can someone give me a sample, how to signal such exception in potential
>> #terminateFromContext: method?
>
> Seems like you would just do "ProcessTerminatedException signal" as
> long as the receiver was the active process. If not the active
> process, you would have to replace the suspended context with a new
> context that will signal the exception as soon as the process is next
> run.
>
> The strange thing about this implementation is that you can write code
> that actually prevents your process from being terminated. I'm not
> saying that's a bad thing (maybe it's even a good thing for certain
> pieces of code) but it certainly changes the semantics of #terminate a
> little. :)

I'm now almost done implementing it.
Its behavior will be different than regular exception handling.
What it will do is:
1. find handler context, if any
2. rewind the stack up to handler context
3. evaluate the handler block (note, that any flow control methods
like "pass, return .. will be simply ignored")
4. repeat from (1) until there are no contexts on stack

so, this all is to ensure, that
a) stack is rewounded
b) all   [... ] on: TerminateProcess  do: [ .. ]  during rewinding is handled

> And that being the case, the name
> ProcessTerminatedException is a bit misleading because it implies that
> the process already *has* been terminated. TerminateProcessException,
> TerminateProcessRequest, or just TerminateProcess would be more
> accurate.
>
Thanks for a better name. I will rename it to 'TerminateProcess'.

> Julian
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list