renamed exitAction: and suspendAction: messages - the old name
authorClaus Gittinger <cg@exept.de>
Sun, 12 Jan 1997 01:11:11 +0100
changeset 2158 aab75d6439d0
parent 2157 436ad20004f4
child 2159 b9255998a855
renamed exitAction: and suspendAction: messages - the old name was confusing. interruptWith is directly executed, if the active process is the receiver.
Process.st
--- a/Process.st	Sat Jan 11 23:59:10 1997 +0100
+++ b/Process.st	Sun Jan 12 01:11:11 1997 +0100
@@ -452,6 +452,31 @@
 
 !Process methodsFor:'accessing-change notifications'!
 
+addExitAction:aBlock
+    "add aBlock to the processes exit actions.
+     This block will be evaluated right before the process dies."
+
+    exitActions isNil ifTrue:[
+        exitActions := OrderedCollection new
+    ].
+    exitActions add:aBlock
+
+    "Created: 12.1.1997 / 00:34:51 / cg"
+!
+
+addSuspendAction:aBlock
+    "add aBlock to the processes suspend actions.
+     This block will be evaluated when a process gets suspended."
+
+    suspendActions isNil ifTrue:[
+        suspendActions := OrderedCollection new
+    ].
+    suspendActions add:aBlock
+
+    "Modified: 13.12.1995 / 13:44:31 / stefan"
+    "Created: 12.1.1997 / 00:35:11 / cg"
+!
+
 emergencySignalHandler
     "return the emergencySignalHandler block.
      See Signal>>documentation for more info."
@@ -466,41 +491,20 @@
     emergencySignalHandler := aOneArgBlock
 !
 
-exitAction:aBlock
-    "add aBlock to the processes exit actions.
-     This block will be evaluated right before the process dies.
-     An argument of nil clears removes all exitActions."
+removeAllExitActions
+    "remove all exit actions."
 
-    aBlock isNil ifTrue:[
-	exitActions := nil.
-	^ self.
-    ].
+    exitActions := nil.
 
-    exitActions isNil ifTrue:[
-	exitActions := OrderedCollection new
-    ].
-    exitActions add:aBlock
-
-    "Modified: 13.12.1995 / 13:44:03 / stefan"
+    "Created: 12.1.1997 / 00:36:02 / cg"
 !
 
-suspendAction:aBlock
-    "add aBlock to the processes suspend actions.
-     This block will be evaluated when a process gets suspended.
-     A nil argument removes all suspendActions."
+removeAllSuspendActions
+    "remove all suspend actions."
 
-    aBlock isNil ifTrue:[
-	suspendActions := nil.
-	^ self.
-    ].
+    suspendActions := nil.
 
-    suspendActions isNil ifTrue:[
-	suspendActions := OrderedCollection new
-    ].
-    suspendActions add:aBlock
-
-    "Created: 13.12.1995 / 13:35:54 / stefan"
-    "Modified: 13.12.1995 / 13:44:31 / stefan"
+    "Created: 12.1.1997 / 00:36:16 / cg"
 ! !
 
 !Process methodsFor:'accessing-stack'!
@@ -616,10 +620,14 @@
      IFF its priority is higher than the current processes priority.
      Otherwise, it will remain suspended, until its time comes."
 
-    self addInterruptAction:aBlock.
-    Processor scheduleForInterrupt:self.
+    Processor activeProcess == self ifTrue:[
+        aBlock value
+    ] ifFalse:[
+        self addInterruptAction:aBlock.
+        Processor scheduleForInterrupt:self.
+    ]
 
-    "Modified: 18.10.1996 / 20:41:27 / cg"
+    "Modified: 12.1.1997 / 00:52:05 / cg"
 !
 
 interruptedIn:aContext
@@ -737,6 +745,45 @@
 %}.
 ! !
 
+!Process methodsFor:'obsolete'!
+
+exitAction:aBlock
+    "Obsoleted by addExitAction: / removeAllExitActions.
+
+     Add aBlock to the processes exit actions.
+     This block will be evaluated right before the process dies.
+     An argument of nil removes all exitActions."
+
+    self obsoleteMethodWarning:'use addExitAction: / removeAllExitActions'.
+
+    aBlock isNil ifTrue:[
+        ^ self removeAllExitActions.
+    ].
+
+    ^ self addExitAction:aBlock
+
+    "Modified: 13.12.1995 / 13:44:03 / stefan"
+    "Modified: 12.1.1997 / 00:39:59 / cg"
+!
+
+suspendAction:aBlock
+    "Obsoleted by addSuspendAction: / removeAllSuspendActions.
+
+     Add aBlock to the processes suspend actions.
+     This block will be evaluated when a process gets suspended.
+     A nil argument removes all suspendActions."
+
+    self obsoleteMethodWarning:'use addSuspendAction: / removeAllSuspendActions'.
+
+    aBlock isNil ifTrue:[
+        ^ self removeAllSuspendActions.
+    ].
+
+    ^ self addSuspendAction:aBlock
+
+    "Modified: 12.1.1997 / 00:38:22 / cg"
+! !
+
 !Process methodsFor:'printing & storing'!
 
 printOn:aStream
@@ -919,9 +966,11 @@
 
     [
         self isDead ifTrue:[^ self].
+
         sema := Semaphore new.
-        self exitAction:[sema signal].
+        self addExitAction:[sema signal].
         sema wait.
+
     ] valueUninterruptably
 
     "
@@ -934,7 +983,7 @@
      Transcript showCR:'done.'
     "
 
-    "Modified: 8.11.1996 / 23:05:27 / cg"
+    "Modified: 12.1.1997 / 00:40:59 / cg"
 !
 
 withLowerPriorityDo:aBlock
@@ -1007,13 +1056,9 @@
         ^ self error:'process is not restartable'
     ].
 
-    Processor activeProcess == self ifTrue:[
-        RestartSignal raise.
-    ] ifFalse:[
-        self interruptWith:[self restart]
-    ]
+    self interruptWith:[RestartSignal raise]
 
-    "Modified: 28.10.1996 / 20:44:51 / cg"
+    "Modified: 12.1.1997 / 00:54:32 / cg"
 !
 
 start
@@ -1124,18 +1169,16 @@
      All unwind actions and the exit-actions (if any)
      will be performed before the process is really terminated."
 
-    Processor activeProcess == self ifTrue:[
+    self interruptWith:[
         Signal noHandlerSignal handle:[:ex |
             ex return.
         ] do:[
             TerminateSignal raise.
         ].
         self terminateNoSignal.
-    ] ifFalse:[
-        self interruptWith:[self terminate]
     ]
 
-    "Modified: 28.10.1996 / 20:44:27 / cg"
+    "Modified: 12.1.1997 / 00:55:14 / cg"
 !
 
 terminateAllSubprocesses
@@ -1223,6 +1266,6 @@
 !Process class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.69 1997-01-10 17:50:33 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.70 1997-01-12 00:11:11 cg Exp $'
 ! !
 Process initialize!