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
This commit is contained in:
parent
9e0df13ec7
commit
699eb31206
9
Timer.st
9
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 [
|
||||
|
|
Reference in New Issue