ProcessorScheduler.st
changeset 11164 8cbff6ed574f
parent 10748 05b053a51d96
child 11284 a854a8b914dc
--- a/ProcessorScheduler.st	Thu Sep 11 09:58:12 2008 +0200
+++ b/ProcessorScheduler.st	Thu Sep 11 10:00:24 2008 +0200
@@ -2770,68 +2770,68 @@
      processes n "{ Class: SmallInteger }"|
 
     anyTimeouts ifFalse:[ ^ self].
+    anyTimeouts := false.
 
     "have to collect the blocks first, then evaluate them. This avoids
      problems due to newly inserted blocks."
 
     now := OperatingSystem getMillisecondTime.
-    blocksToEvaluate := nil.
     n := timeoutArray size.
-    anyTimeouts := false.
     1 to:n do:[:index |
-	aTime := timeoutArray at:index.
-	aTime notNil ifTrue:[
-	    (OperatingSystem millisecondTime:aTime isAfter:now) ifFalse:[
-		"this one should be triggered"
-
-		sema := timeoutSemaphoreArray at:index.
-		sema notNil ifTrue:[
-		    timeoutSemaphoreArray at:index put:nil.
-		    sema signalOnce.
-		] ifFalse:[
-		    "to support pure-events"
-		    block := timeoutActionArray at:index.
-		    block notNil ifTrue:[
-			blocksToEvaluate isNil ifTrue:[
-			    blocksToEvaluate := OrderedCollection new:10.
-			    processes := OrderedCollection new:10.
-			].
-			blocksToEvaluate add:block.
-			processes add:(timeoutProcessArray at:index).
-			timeoutActionArray at:index put:nil.
-			timeoutProcessArray at:index put:nil.
-		    ]
-		].
-		timeoutArray at:index put:nil.
-	    ] ifTrue:[
-		anyTimeouts := true
-	    ]
-	]
+        aTime := timeoutArray at:index.
+        aTime notNil ifTrue:[
+            (OperatingSystem millisecondTime:now isAfter:aTime) ifTrue:[
+                "this one should be triggered"
+
+                sema := timeoutSemaphoreArray at:index.
+                sema notNil ifTrue:[
+                    timeoutSemaphoreArray at:index put:nil.
+                    sema signalOnce.
+                ] ifFalse:[
+                    "to support pure-events"
+                    block := timeoutActionArray at:index.
+                    block notNil ifTrue:[
+                        blocksToEvaluate isNil ifTrue:[
+                            blocksToEvaluate := OrderedCollection new:10.
+                            processes := OrderedCollection new:10.
+                        ].
+                        blocksToEvaluate add:block.
+                        processes add:(timeoutProcessArray at:index).
+                        timeoutActionArray at:index put:nil.
+                        timeoutProcessArray at:index put:nil.
+                    ]
+                ].
+                timeoutArray at:index put:nil.
+            ] ifFalse:[
+                "there are still pending timeouts"
+                anyTimeouts := true
+            ]
+        ]
     ].
 
     blocksToEvaluate notNil ifTrue:[
-	blocksToEvaluate keysAndValuesDo:[:index :block |
-	    |p|
-
-	    p := processes at:index.
-	    (p isNil or:[p == scheduler or:[PureEventDriven]]) ifTrue:[
-		block value
-	    ] ifFalse:[
-		p isDead ifTrue:[
-
-		    "/ a timedBlock for a process which has already terminated
-		    "/ issue a warning and do not execute it.
-		    "/ (exeuting here may be dangerous, since it would run at scheduler priority here,
-		    "/  and thereby could block the whole smalltalk system.
-		    "/  For this reason is it IGNORED here.)
-
-		    ('ProcessorScheduler [warning]: cannot evaluate timedBlock for dead process: ''' , p name , '''') infoPrintCR.
-		    ('ProcessorScheduler [warning]: the timedBlock is: ' , block displayString) infoPrintCR.
-		] ifFalse:[
-		    p interruptWith:block
-		]
-	    ]
-	]
+        blocksToEvaluate keysAndValuesDo:[:index :block |
+            |p|
+
+            p := processes at:index.
+            (p isNil or:[p == scheduler or:[PureEventDriven]]) ifTrue:[
+                block value
+            ] ifFalse:[
+                p isDead ifTrue:[
+
+                    "/ a timedBlock for a process which has already terminated
+                    "/ issue a warning and do not execute it.
+                    "/ (exeuting here may be dangerous, since it would run at scheduler priority here,
+                    "/  and thereby could block the whole smalltalk system.
+                    "/  For this reason is it IGNORED here.)
+
+                    ('ProcessorScheduler [warning]: cannot evaluate timedBlock for dead process: ''' , p name , '''') infoPrintCR.
+                    ('ProcessorScheduler [warning]: the timedBlock is: ' , block displayString) infoPrintCR.
+                ] ifFalse:[
+                    p interruptWith:block
+                ]
+            ]
+        ]
     ]
 
     "Modified: / 9.11.1998 / 21:25:02 / cg"
@@ -3213,23 +3213,21 @@
 
     n := timeoutArray size.
     1 to:n do:[:index |
-	aTime := timeoutArray at:index.
-	aTime notNil ifTrue:[
-	    now isNil ifTrue:[
-		now := OperatingSystem getMillisecondTime.
-	    ].
-	    (OperatingSystem millisecondTime:aTime isAfter:now) ifFalse:[^ 0].
-	    delta := OperatingSystem millisecondTimeDeltaBetween:aTime and:now.
-	    delta < 0 ifTrue:[
-		'Processor [warning]: negative time delta' errorPrintCR.
-		delta := 10.
-	    ].
-	    minDelta isNil ifTrue:[
-		minDelta := delta
-	    ] ifFalse:[
-		minDelta := minDelta min:delta
-	    ]
-	]
+        aTime := timeoutArray at:index.
+        aTime notNil ifTrue:[
+            now isNil ifTrue:[
+                now := OperatingSystem getMillisecondTime.
+            ].
+            delta := OperatingSystem millisecondTimeDeltaBetween:aTime and:now.
+            delta <= 0 ifTrue:[
+                ^ 0.
+            ].
+            minDelta isNil ifTrue:[
+                minDelta := delta
+            ] ifFalse:[
+                minDelta := minDelta min:delta
+            ]
+        ]
     ].
 
     ^ minDelta
@@ -3354,7 +3352,7 @@
 !ProcessorScheduler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.245 2007-10-22 11:38:41 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.246 2008-09-11 08:00:24 stefan Exp $'
 ! !
 
 ProcessorScheduler initialize!