summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-07-21 12:39:52 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-07-21 12:41:22 +0200
commit699eb31206e617e31b2f36ef312ff7a93fada225 (patch)
tree41578450f86d1f596f86ebe87aeda0e4c8d2c840
parent9e0df13ec7f54813129f5f9851cb233445455608 (diff)
timer: Assign the loop _before_ running the process
Avoid a potential race condition. Assign the loop variable before starting the process. Otherwise the effect on loop could be that a terminated process is being assigned. Spotted while reviewing a problem Norbert experienced in Pharo
-rw-r--r--Timer.st9
1 files changed, 6 insertions, 3 deletions
diff --git a/Timer.st b/Timer.st
index b6a31f1..909f77b 100644
--- a/Timer.st
+++ b/Timer.st
@@ -107,9 +107,12 @@ bit difficult to do this race free.'>
<category: 'creation'>
processExited := Semaphore new.
- loop := [[Processor activeProcess name: 'Osmo Timers'.
- self runTimers
- ] ensure: [processExited signal. loop := nil]] fork
+
+ loop := [[self runTimers] ensure: [
+ processExited signal.
+ loop := nil]] newProcess.
+ loop name: 'Osmo Timers'.
+ loop resume.
]
scheduleInSeconds: aDelay block: aBlock [