On May 3, 2013, at 9:44 AM, Henrik Johansen wrote: >> oh.. on second thought, even better.. >> >> processToInterrupt >> "look for best candidate to interrupt: >> first who is not weak-finalization process >> and only then weak-finalization process, if nothing left to >> interrupt. >> >> filter out the idle process, since killing it is fatal >> " >> | list | >> >> list := OrderedCollection new. >> Processor scanSchedule: [:p | >> "gather everything but idle process, and processes whose >> suspendedContext sender == nil, >> which usually means that process is only scheduled but had no >> chance to run" >> >> ((p ~~ Processor backgroundProcess) and: [ p suspendedContext >> sender notNil ]) >> ifTrue: [ list add: p ] ] startingAt: Processor >> activePriority. >> >> "now answer first process in list, skipping the finalization process" >> list do: [:p | p == WeakArray runningFinalizationProcess ifFalse: [ ^ >> p ] ]. >> >> "now answer first process , if any ,otherwise answer ui process by >> default" >> ^ list isEmpty ifTrue: [ UIManager default uiProcess ] ifFalse: [ list >> first ] >> >> >> so it interrupts >> even if i do >> >> 1 hour wait >> >> in workspace > Something like that yes, or maybe even: > processToInterrupt > "Look for best candidate to interrupt: > - any scheduled non-finalization process of lower priority > - the weak-finalization process, if scheduled > - the UI process > Never interrupt the idle process, since killing it is fatal" > > | fallback | > > fallback := UIManager default uiProcess. > Processor > scanSchedule: [:p | > "suspendedContext sender == nil usually means that > process is only scheduled but had no chance to run" > ((p ~~ Processor backgroundProcess) and: [ p > suspendedContext sender notNil ifTrue: [ > p ~~ WeakArray runningFinalizationProcess > ifTrue: [^p] > ifFalse: [fallback := p]] ] > startingAt: Processor activePriority. > ^fallback > > Cheers, > Henry (That's just rewritten btw, functionality is the same)
Cheers, Henry