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 |
On Mon, Feb 22, 2016 at 11:08 PM, Ben Coman <[hidden email]> wrote:
> 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 Further curiosity, the #ensure block is executed by the 'inner' process... Transcript clear; crShow: Processor activeProcess; show:' - outside'. p1 := [ [ Transcript crShow: Processor activeProcess; show: ' - inside'. 1 second wait. ] ensure: [ Transcript crShow: Processor activeProcess; show: ' - curtailed' . ] ] newProcess priority: 41. p1 resume. p1 terminate. ==> a Process(959980800) in nil - outside a Process(636470784) in nil - inside a Process(636470784) in nil - curtailed And wrapping an #ensure: around an #ifCurtailed: makes its block be executed by the 'inner' process... Transcript clear; crShow: Processor activeProcess; show:' - outside'. p1 := [ [ [ Transcript crShow: Processor activeProcess; show: ' - inside'. 1 second wait. ] ifCurtailed: [ Transcript crShow: Processor activeProcess; show: ' - curtailed' ] ] ensure: [ Transcript crShow: Processor activeProcess; show: ' - ensure' . ] ] newProcess priority: 41. p1 resume. p1 terminate. ==> a Process(959980800) in nil - outside a Process(663403776) in nil - inside a Process(663403776) in nil - curtailed a Process(663403776) in nil - ensure BUT!!! Huh!?!? The original example now has the curtailed block executed by the 'inside' process... 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(959980800) in nil - outside a Process(329852416) in nil - inside a Process(329852416) in nil - curtailed cheers -ben |
Free forum by Nabble | Edit this page |