ProcessorScheduler.st
changeset 18774 a262834431c7
parent 18673 5bc94bc1ebbb
child 18775 98c6a42b8875
--- a/ProcessorScheduler.st	Wed Sep 30 04:03:07 2015 +0000
+++ b/ProcessorScheduler.st	Wed Sep 30 14:57:02 2015 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
 	      All Rights Reserved
@@ -3059,6 +3061,34 @@
     "Modified: 23.9.1996 / 14:35:09 / cg"
 !
 
+removeTimeoutWithID:anID object:aBlockOrSemaphore
+    "remove the timeOut with anID (as returned by #addTimedBlock)
+     from the list of time-scheduled-blocks.
+     If aBlockOrSempahore is not nil, check if the id is really for the block
+     or for the semphore."
+
+    |index "{ Class: SmallInteger }"
+     wasBlocked|
+
+    index := anID.
+    (index notNil and:[index > 0]) ifTrue:[
+        wasBlocked := OperatingSystem blockInterrupts.
+
+        (aBlockOrSemaphore notNil 
+          and:[(timeoutActionArray at:index) ~~ aBlockOrSemaphore
+          and:[(timeoutSemaphoreArray at:index) ~~ aBlockOrSemaphore]]) ifTrue:[
+            'Processor: trying to remove stale timeout id - ignored' errorPrintCR.
+        ] ifFalse:[
+            timeoutArray at:index put:nil.
+            timeoutActionArray at:index put:nil.
+            timeoutSemaphoreArray at:index put:nil.
+            timeoutProcessArray at:index put:nil.
+        ].
+
+        wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+    ]
+!
+
 timeoutHandlerProcess
     (timeoutHandlerProcess isNil or:[timeoutHandlerProcess isDead]) ifTrue:[
 	timeoutHandlerProcess :=