Saving and resuming an exception context?
Ned Konz
ned at squeakland.org
Thu Mar 25 00:34:35 UTC 2004
Perhaps someone (Anthony?) can tell me how to do this (preferably with a stock
VM):
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.
That is:
Notification subclass: FreezeMe ...
MyClass>>runBlock: aBlock frozenContext: oldFrozenState
| frozenState |
frozenState := nil.
[ oldFrozenState
ifNotNil: [ oldFrozenState resumeSomehow ]
ifNil: [ aBlock value ] ]
on: FreezeMe
do: [ :ex | frozenState := ex freezeForLater ].
^frozenState
Then I could do this:
frozen := self runBlock: someBlock frozenContext: frozen.
and go off and do something else and come back later and repeat it at will.
The block would run until it signaled a FreezeMe.
Of course, what I need here is a definition for
Exception>>freezeForLater
and one for
(frozen)>>resumeSomehow
Is there an easy way to do this?
Thanks,
--
Ned Konz
http://bike-nomad.com/squeak/
More information about the Squeak-dev
mailing list
|