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:
parent
ff6db68e34
commit
9807973a46
|
@ -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.
|
||||
]
|
||||
]
|
||||
|
||||
|
|
Reference in New Issue