--- a/ProcessorScheduler.st Mon Sep 23 14:05:38 1996 +0200
+++ b/ProcessorScheduler.st Mon Sep 23 14:40:14 1996 +0200
@@ -1674,9 +1674,12 @@
(if it is running, the interrupt will occur in whatever method it is
executing; if it is suspended, it will be resumed).
The block will be removed from the timed-block list after evaluation
- (i.e. it will trigger only once)."
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
^ self addTimedBlock:aBlock for:activeProcess afterMilliseconds:delta
+
+ "Modified: 23.9.1996 / 14:33:59 / cg"
!
addTimedBlock:aBlock afterSeconds:delta
@@ -1686,9 +1689,12 @@
(if it is running, the interrupt will occur in whatever method it is
executing; if it is suspended, it will be resumed).
The block will be removed from the timed-block list after evaluation
- (i.e. it will trigger only once)."
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
- self addTimedBlock:aBlock for:activeProcess afterMilliseconds:(delta * 1000) rounded
+ ^ self addTimedBlock:aBlock for:activeProcess afterMilliseconds:(delta * 1000) rounded
+
+ "Modified: 23.9.1996 / 14:34:04 / cg"
!
addTimedBlock:aBlock atMilliseconds:aMillisecondTime
@@ -1699,9 +1705,12 @@
(if it is running, the interrupt will occur in whatever method it is
executing; if it is suspended, it will be resumed).
The block will be removed from the timed-block list after evaluation
- (i.e. it will trigger only once)."
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
- self addTimedBlock:aBlock for:activeProcess atMilliseconds:aMillisecondTime
+ ^ self addTimedBlock:aBlock for:activeProcess atMilliseconds:aMillisecondTime
+
+ "Modified: 23.9.1996 / 14:34:09 / cg"
!
addTimedBlock:aBlock for:aProcess afterMilliseconds:delta
@@ -1713,15 +1722,19 @@
If aProcess is nil, the block will be evaluated by the scheduler itself
(which is dangerous - the block should not raise any error conditions).
The block will be removed from the timed-block list after evaluation
- (i.e. it will trigger only once)."
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
- |now then wasBlocked|
+ |now then wasBlocked id|
wasBlocked := OperatingSystem blockInterrupts.
now := OperatingSystem getMillisecondTime.
then := OperatingSystem millisecondTimeAdd:now and:delta.
- self addTimedBlock:aBlock for:aProcess atMilliseconds:then.
+ id := self addTimedBlock:aBlock for:aProcess atMilliseconds:then.
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ ^ id
+
+ "Modified: 23.9.1996 / 14:34:13 / cg"
!
addTimedBlock:aBlock for:aProcess afterSeconds:delta
@@ -1733,9 +1746,12 @@
If aProcess is nil, the block will be evaluated by the scheduler itself
(which is dangerous - the block should not raise any error conditions).
The block will be removed from the timed-block list after evaluation
- (i.e. it will trigger only once)."
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
- self addTimedBlock:aBlock for:aProcess afterMilliseconds:(delta * 1000) rounded
+ ^ self addTimedBlock:aBlock for:aProcess afterMilliseconds:(delta * 1000) rounded
+
+ "Modified: 23.9.1996 / 14:34:18 / cg"
!
addTimedBlock:aBlock for:aProcess atMilliseconds:aMillisecondTime
@@ -1752,7 +1768,8 @@
whatever method it is executing; if suspended at trigger time, it will be
resumed.
The block will be removed from the timed-block list after evaluation
- (i.e. it will trigger only once)."
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
|index "{ Class: SmallInteger }"
wasBlocked|
@@ -1760,24 +1777,79 @@
wasBlocked := OperatingSystem blockInterrupts.
index := timeoutActionArray identityIndexOf:aBlock startingAt:1.
index ~~ 0 ifTrue:[
- timeoutArray at:index put:aMillisecondTime
+ timeoutArray at:index put:aMillisecondTime
] ifFalse:[
- index := timeoutArray indexOf:nil.
- index ~~ 0 ifTrue:[
- timeoutArray at:index put:aMillisecondTime.
- timeoutActionArray at:index put:aBlock.
- timeoutSemaphoreArray at:index put:nil.
- timeoutProcessArray at:index put:aProcess
- ] ifFalse:[
- timeoutArray := timeoutArray copyWith:aMillisecondTime.
- timeoutActionArray := timeoutActionArray copyWith:aBlock.
- timeoutSemaphoreArray := timeoutSemaphoreArray copyWith:nil.
- timeoutProcessArray := timeoutProcessArray copyWith:aProcess.
- ].
+ index := timeoutArray indexOf:nil.
+ index ~~ 0 ifTrue:[
+ timeoutArray at:index put:aMillisecondTime.
+ timeoutActionArray at:index put:aBlock.
+ timeoutSemaphoreArray at:index put:nil.
+ timeoutProcessArray at:index put:aProcess
+ ] ifFalse:[
+ timeoutArray := timeoutArray copyWith:aMillisecondTime.
+ timeoutActionArray := timeoutActionArray copyWith:aBlock.
+ timeoutSemaphoreArray := timeoutSemaphoreArray copyWith:nil.
+ timeoutProcessArray := timeoutProcessArray copyWith:aProcess.
+ index := timeoutArray size.
+ ].
].
anyTimeouts := true.
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ ^ index
+
+ "Modified: 23.9.1996 / 14:34:23 / cg"
+!
+
+addTimeoutFunctionCall:anExternalFunction for:aProcess afterMilliseconds:delta with:argument
+ "prepare for an external function to be called with a single argument
+ after some millisecond-Delay.
+ If aProcess is nil, the block will be evaluated by the scheduler itself,
+ otherwise, that process will be interrupted and the function is performed
+ in this processes context.
+ The callBack will be removed from the timed-block list after evaluation
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
+
+ |now then wasBlocked id|
+
+ wasBlocked := OperatingSystem blockInterrupts.
+ now := OperatingSystem getMillisecondTime.
+ then := OperatingSystem millisecondTimeAdd:now and:delta.
+
+ id := self
+ addTimeoutFunctionCall:anExternalFunction
+ for:aProcess
+ atMilliseconds:delta
+ with:argument.
+
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+ ^ id
+
+ "Created: 23.9.1996 / 14:28:27 / cg"
+ "Modified: 23.9.1996 / 14:34:42 / cg"
+!
+
+addTimeoutFunctionCall:anExternalFunction for:aProcess atMilliseconds:delta with:argument
+ "prepare for an external function to be called with a single argument
+ at some millisecond-time.
+ If aProcess is nil, the block will be evaluated by the scheduler itself,
+ otherwise, that process will be interrupted and the function is performed
+ in this processes context.
+ The callBack will be removed from the timed-block list after evaluation
+ (i.e. it will trigger only once).
+ Returns an ID, which can be used in #removeTimeoutWidthID:"
+
+ |action|
+
+ action := [anExternalFunction callWith:argument].
+ ^ self
+ addTimedBlock:action
+ for:aProcess
+ atMilliseconds:delta.
+
+ "Created: 23.9.1996 / 14:29:30 / cg"
+ "Modified: 23.9.1996 / 14:34:57 / cg"
!
evaluateTimeouts
@@ -1855,6 +1927,27 @@
timeoutProcessArray at:index put:nil.
].
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+!
+
+removeTimedBlockWithID:anID
+ "remove the timeOut with anID (as returned by #addTimedBlock)
+ from the list of time-sceduled-blocks."
+
+ |index "{ Class: SmallInteger }"
+ wasBlocked|
+
+ wasBlocked := OperatingSystem blockInterrupts.
+ index := anID.
+ (index ~~ 0) ifTrue:[
+ timeoutArray at:index put:nil.
+ timeoutActionArray at:index put:nil.
+ timeoutSemaphoreArray at:index put:nil.
+ timeoutProcessArray at:index put:nil.
+ ].
+ wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
+
+ "Created: 23.9.1996 / 14:32:33 / cg"
+ "Modified: 23.9.1996 / 14:35:09 / cg"
! !
!ProcessorScheduler methodsFor:'waiting'!
@@ -2104,6 +2197,6 @@
!ProcessorScheduler class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.89 1996-08-29 20:52:10 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/ProcessorScheduler.st,v 1.90 1996-09-23 12:40:14 cg Exp $'
! !
ProcessorScheduler initialize!