diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-21 12:39:52 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2014-07-21 12:41:22 +0200 |
commit | 699eb31206e617e31b2f36ef312ff7a93fada225 (patch) | |
tree | 41578450f86d1f596f86ebe87aeda0e4c8d2c840 | |
parent | 9e0df13ec7f54813129f5f9851cb233445455608 (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.st | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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 [ |