From 9807973a46505c4613ca72d9e5ff66e008a7b480 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 20 Feb 2013 09:17:29 +0100 Subject: [PATCH] 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. --- Dispatcher.st | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Dispatcher.st b/Dispatcher.st index 4015378..4ddcaec 100644 --- a/Dispatcher.st +++ b/Dispatcher.st @@ -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. ] ]