On 04/03/2011 03:34 PM, Paolo Bonzini wrote:
>> Is there a kind of Exception that can be thrown but not
>> caught by a 'imprecise' on:do?
>
> No. One may say that "on: Exception" and "on: Notification" are
> always wrong and should never be used ("on: Warning" and "on: Error"
> instead are usually fine). Feel free to write code as if they never
> appeared in code.
Hi,
maybe you could help me to understand the Process/BlockClosure/Exception
interaction. I do have two issues. The first is that even if I manage to call
the timeout block I am still returning to the Delay and do not leave the
block. Any idea how I could leave the delay, execute all ensure blocks inside
the timeout?
Eval [
[(Delay forSeconds: 100000) wait] timeout: 1 do: ['Timedout' printNl].
]
Notification subclass: TimeoutNotification [
]
BlockClosure extend [
timeout: seconds do: aBlock [
| delay sem proc value |
sem := Semaphore new.
proc := Processor activeProcess.
"Start the waiting."
[[
"Start a process to wait in and then signal"
[| delay |
delay := Delay forSeconds: seconds.
"Wait and see if it is timed out"
(delay timedWaitOn: sem) ifTrue: [
proc queueInterrupt: [ ^ TimeoutNotification signal].
].
] fork.
^ self value.
] ensure: [sem signal]
] on: TimeoutNotification do: [
thisContext backtrace.
^ aBlock value]
]
]
_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk