[Vm-dev] #ifCurtailed: multi-thread semantics

Ben Coman btc at openinworld.com
Mon Feb 22 15:08:07 UTC 2016


Just a curiousity. I learnt something new today...
#ifCurtailed blocks are processed in the outer most thread.

    Transcript clear; crShow: Processor activeProcess; show:' - outside'.
     p1 :=
     [    [   Transcript crShow: Processor activeProcess; show: ' - inside'.
              1 second wait.
          ] ifCurtailed: [ Transcript crShow: Processor activeProcess;
show: ' - curtailed' . ]
    ] newProcess priority: 41.
    p1 resume.
    p1 terminate.
==>
a Process(304957184) in nil - outside
a Process(680396800) in nil - inside
a Process(304957184) in nil - curtailed

This makes some sense since (I guess) the inside thread is terminated
before the curtailed block executes.  However another curiousity...

    Transcript clear; crShow: Processor activeProcess; show:' - outside'.
     p1 :=
     [   Transcript crShow: Processor activeProcess; show: ' - middle'.
          p2 :=
          [   [   Transcript crShow: Processor activeProcess; show: ' - inside'.
                    1 second wait.
               ] ifCurtailed: [ Transcript crShow: Processor
activeProcess; show: ' - curtailed' .
               2 seconds wait ]
           ] fork.
           3 second wait.
    ] newProcess priority: 41.
    p1 resume.
    p2 terminate.
==>
a Process(304957184) in nil - outside
a Process(146580480) in nil - middle
a Process(417340928) in nil - inside
a Process(304957184) in nil - curtailed

...why does the curtailed block execute in outside thread rather than
the middle thread which still exists?

Also interesting is that if the curtailed code contains a wait, it
blocks the whole UI.

cheers -ben

btw, I added...
  Process>>printOn: aStream
      super printOn: aStream.
      aStream nextPutAll: '(' , self hash printString , ') in '.
      suspendedContext printOn: aStream


More information about the Vm-dev mailing list