[squeak-dev] Re: Process conflict when redisplaying World
andreas.raab at gmx.de
Wed May 6 17:08:15 UTC 2009
Trygve Reenskaug wrote:
> Thanks Andreas, for your very quick answer.
> Stepping was the first mechanism I tried, but the program got very
> complex keeping track of what to do at each step. My goal is to have a
> simple, readable program and the stepping alternative was neither simple
> nor readable. So I'm trying other solutions.
In that case you need to define what a "stable" state for your
simulation is. Once you have that you can implement something where you
pass a semaphore into the simulation that is being signaled when the
simulation should make progress, and that the simulation waits on when
it's in a stable state. Along the lines of:
sema := Semaphore new.
sema wait. "wait for the simulation to begin"
simulator syncSema: sema.
] forkAt: Processor userInterruptPriority.
"Allow our simulation to run until it has reached stable state"
Then anywhere in the simulation where it's safe to do so, just throw in
a sema wait.
More information about the Squeak-dev