smalltalk
/
osmo-st-core
Archived
1
0
Fork 0

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:
Holger Hans Peter Freyther 2014-07-21 12:39:52 +02:00
parent 9e0df13ec7
commit 699eb31206
1 changed files with 6 additions and 3 deletions

View File

@ -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 [