Benjamin Van Ryseghem-2 wrote
Probably because the fork create a new process at priority 40, which is also the priority of the ui process.
So the processor dispatch between them I guess :)
I see where Morphic may give an opportunity to switch back to my block in #interCyclePause:, but when does the processor get a chance to switch out of my block? I tried debugging, but couldn't figure out a way to hook in before Morphic got control back (e.g. I put a haltOnce in Process>>resume, which was never called apparently; and putting a halt in the block itself just loops through the block repeatedly).
Here's the code accessing a global variable for logging:
m := MyMorph new openInWorld. "MyMorph>>#step does - Messages add: 'step'."
Messages := OrderedCollection new.
trues := 0.
[
(1 to: 250000000) do: [ :e |
"(Delay forMilliseconds: 100) wait."
e \\ 5000000 == 0 ifTrue: [
Messages add: 'block - true'.
trues := trues + 1 ] ].
m delete.
WorldState addDeferredUIMessage: [Messages explore] ] forkAt: 30.
p.s. If I fork at 30, there is approximately a 1:1 interleaving of the world stepping and the ifTrue: part being executed. If I fork at 40 (UI priority), there is (very roughly) a 5:1 between the ifTrue: and world stepping, but it's very inconsistent.
I did not protect access to the global Messages, because I was worried the lock would change the process scheduling.
Cheers,
Sean