Saving and resuming an exception context?

Ned Konz ned at squeakland.org
Thu Mar 25 14:51:55 UTC 2004


On Thursday 25 March 2004 1:12 am, Avi Bryant wrote:
> On Mar 24, 2004, at 4:34 PM, Ned Konz wrote:
> > I'd like to be able to evaluate a block, and upon an exception freeze
> > the
> > execution state so that it can be resumed later (not necessarily from
> > the
> > same context). Kind of like a continuation, but without replacing the
> > current
> > stack context.
>
> Why not replacing the current stack context?  Is that an implementation
> detail or an actual requirement?

I can't replace the *entire* stack context, because I'm going to be doing this 
from the UI thread (which isn't being actively managed).

> FWIW, this is how I think you would implement it using continuations.
> It has the interesting property that you can resume multiple times from
> the same frozen state.  Not tested, though.
>
> MyClass>>runBlock: aBlock frozenContext: oldFrozenState
>
> 	|frozen|
>
> 	frozen := oldFrozenState ifNil: [
> 			[:f ||freeze|
> 			freeze := f.
> 			aBlock
> 		  		on: FreezeMe
>     				do: [:ex | freeze := Continuation currentDo: [:cc | freeze
> value: cc].  ex resume]]].
> 	^ Continuation currentDo: [:cc | frozen value: cc. nil]

Interesting. What's the status of continuation support in the current image 
and VM?

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list