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

Igor Stasenko siguctua at gmail.com
Fri May 1 10:11:30 UTC 2009


Another improvement would be to marry the process termination with
exception handling,
and nicely signal ProcessTerminatedException.
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?

2009/5/1 Igor Stasenko <siguctua at gmail.com>:
> There are a potential of having incorrect behavior , when terminating
> a preempted or waiting process:
>
> with introduction of ProcessLocalVariable, it is essential that
> context unwinding procedure should be performed only
> for currently active process.
>
> Here the proposal how to ensure this:
>
> if terminating process is not active process we should do the following:
>
> suspendedContext := proc suspendedContext.
> currentProces := Processor activeProcess.
> proc suspendedContext:  [  Processor activeProcess
> terminateFromContext: suspendedContext. Processor switchToProcess:
> currentProcess ] asContext.
> Processor switchToProcess: proc.
>
> here #switchToProcess: is explicit switch (bypassing scheduling logic).
>
> If we don't care about immediate termination of process and getting
> back to process who initiated termination as soon as possible, then
> simply do:
> process terminateSoon.
>
> which can be implemented as:
>
> Process>>terminateSoon
> | termContext |
> termContext := suspendedContext.
> suspendedContext := [  self terminateFromContext: termContext. self
> suspend ] asContext.
> Processor yield.
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list