smalltalk
/
osmo-st-core
Archived
1
0
Fork 0

dispatcher: Dispatch the blocks in a new process to avoid termination

Avoid the dispatcher process from being terminated. Dispatch the
block in a new context. This is easier than detecting the termination
and then respawn it.
This commit is contained in:
Holger Hans Peter Freyther 2013-02-20 09:17:29 +01:00
parent ff6db68e34
commit 9807973a46
1 changed files with 9 additions and 2 deletions

View File

@ -52,12 +52,19 @@ Object subclass: Dispatcher [
]
dispatch [
| block |
| block sem |
block := queue next.
sem := Semaphore new.
"Run the code in a new process as the debugger might terminate this
and then the dispatcher would not dispatch anymore. Use a Semaphore
to make sure we keep on processing items in order."
[[
block on: Error do: [:error |
error logException: 'dispatch failed on "%1".' % {block} area: #core.
]
]] ensure: [sem signal]] fork.
sem wait.
]
]