--- a/Process.st Tue Oct 01 23:46:46 2019 +0200
+++ b/Process.st Thu Oct 03 11:54:06 2019 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
@@ -1756,7 +1754,7 @@
"Created: 6.8.1997 / 15:40:02 / cg"
! !
-!Process methodsFor:'startup'!
+!Process methodsFor:'start & stop'!
imageRestart
"restart the process from the beginning.
@@ -1849,111 +1847,6 @@
"Modified: / 31-01-2017 / 16:41:05 / stefan"
"Modified: / 24-05-2018 / 21:04:12 / Claus Gittinger"
"Modified: / 11-04-2019 / 14:56:09 / Stefan Vogel"
-! !
-
-!Process methodsFor:'suspend & resume'!
-
-abort
- "raise an AbortOperationRequest in the receiver process.
- Most processes willing to handle this will return to some save state
- (typically, some kind of event loop).
- If not handled, this will result in termination of the process."
-
- Processor activeProcess == self ifTrue:[
- AbortOperationRequest raiseRequest
- ] ifFalse:[
- self interruptWith:[
- AbortOperationRequest raiseRequest
- ].
- ]
-
- "Modified: / 16.11.2001 / 17:39:18 / cg"
-!
-
-resume
- "resume the receiver process"
-
- state == #stopped ifTrue:[
- state := #run.
- ].
- Processor resume:self
-!
-
-resumeForSingleSend
- "resume the receiver process, but only let it execute a single send."
-
- Processor resumeForSingleSend:self
-!
-
-stop
- "suspend the receiver process - will continue to run when a resume is sent.
- A stopped process will not be resumed for interrupt processing."
-
- self suspendWithState:#stopped.
-
- "Modified: / 13.12.1995 / 13:22:58 / stefan"
- "Modified: / 27.7.1998 / 23:37:15 / cg"
-!
-
-suspend
- "suspend the receiver process - it will continue to run when a resume is sent.
- Notice, that an interrupt will also resume the receiver,
- so any waiting code should be prepared for premature return from
- a suspend (see wait code in Semaphore).
- Use #stop for a hard-suspend, which is not affected by interrupts."
-
- self suspendWithState:#suspended
-
- "Modified: 17.6.1996 / 14:41:34 / cg"
-!
-
-suspendWithState:aStateSymbol
- "like suspend, this suspends the receiver process until a resume is sent.
- This sets the state to the argument, aStateSymbol, which is shown
- in the ProcessMonitor (instead of #suspended).
- (i.e. no new functionality, but a bit more debuggability)
- Notice, that an interrupt will also resume the receiver,
- so any waiting code should be prepared for premature return from
- a suspend (see wait code in Semaphore).
- Use #stop for a hard-suspend, which is not affected by interrupts.
- Should be called with interrupts disabled."
-
- <resource: #skipInDebuggersWalkBack>
-
- suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll].
- suspendActions notNil ifTrue:[
- |savedState|
-
- savedState := state.
- state := #aboutToSuspend.
- suspendActions do:[:action | action value].
- state ~~ #aboutToSuspend ifTrue:[
- "/ mhmh - one of the suspendActions lead to making me active again;
- "/ bail out.
- "/ This fixes the Semaphore was signalled, but process did not run error,
- "/ which can happen when a process with a suspend action goes into a readWait,
- "/ and the suspend action does a thread switch, and the readWait semaphore gets
- "/ signalled before we come back here. Then the semaphore wakeup will have already
- "/ place me back into the run state, so I should not go into a suspend below.
- ^ self.
- ].
- state := savedState.
- ].
-
- "
- this is a bit of a kludge: allow someone else to
- set the state to something like #ioWait etc.
- In this case, do not set the receiver's state to #suspend.
- (All of this to enhance the output of the process monitor ...)
- "
- (state == #active
- or:[state == #run
- or:[aStateSymbol == #stopped]]) ifTrue:[
- state := aStateSymbol.
- ].
- Processor suspend:self
-
- "Modified: / 30-05-2018 / 13:57:00 / Claus Gittinger"
!
terminate
@@ -2229,6 +2122,111 @@
"Modified (format): / 11-09-2019 / 12:02:34 / Stefan Vogel"
! !
+!Process methodsFor:'suspend & resume'!
+
+abort
+ "raise an AbortOperationRequest in the receiver process.
+ Most processes willing to handle this will return to some save state
+ (typically, some kind of event loop).
+ If not handled, this will result in termination of the process."
+
+ Processor activeProcess == self ifTrue:[
+ AbortOperationRequest raiseRequest
+ ] ifFalse:[
+ self interruptWith:[
+ AbortOperationRequest raiseRequest
+ ].
+ ]
+
+ "Modified: / 16.11.2001 / 17:39:18 / cg"
+!
+
+resume
+ "resume the receiver process"
+
+ state == #stopped ifTrue:[
+ state := #run.
+ ].
+ Processor resume:self
+!
+
+resumeForSingleSend
+ "resume the receiver process, but only let it execute a single send."
+
+ Processor resumeForSingleSend:self
+!
+
+stop
+ "suspend the receiver process - will continue to run when a resume is sent.
+ A stopped process will not be resumed for interrupt processing."
+
+ self suspendWithState:#stopped.
+
+ "Modified: / 13.12.1995 / 13:22:58 / stefan"
+ "Modified: / 27.7.1998 / 23:37:15 / cg"
+!
+
+suspend
+ "suspend the receiver process - it will continue to run when a resume is sent.
+ Notice, that an interrupt will also resume the receiver,
+ so any waiting code should be prepared for premature return from
+ a suspend (see wait code in Semaphore).
+ Use #stop for a hard-suspend, which is not affected by interrupts."
+
+ self suspendWithState:#suspended
+
+ "Modified: 17.6.1996 / 14:41:34 / cg"
+!
+
+suspendWithState:aStateSymbol
+ "like suspend, this suspends the receiver process until a resume is sent.
+ This sets the state to the argument, aStateSymbol, which is shown
+ in the ProcessMonitor (instead of #suspended).
+ (i.e. no new functionality, but a bit more debuggability)
+ Notice, that an interrupt will also resume the receiver,
+ so any waiting code should be prepared for premature return from
+ a suspend (see wait code in Semaphore).
+ Use #stop for a hard-suspend, which is not affected by interrupts.
+ Should be called with interrupts disabled."
+
+ <resource: #skipInDebuggersWalkBack>
+
+ suspendSemaphore notNil ifTrue:[suspendSemaphore signalForAll].
+ suspendActions notNil ifTrue:[
+ |savedState|
+
+ savedState := state.
+ state := #aboutToSuspend.
+ suspendActions do:[:action | action value].
+ state ~~ #aboutToSuspend ifTrue:[
+ "/ mhmh - one of the suspendActions lead to making me active again;
+ "/ bail out.
+ "/ This fixes the Semaphore was signalled, but process did not run error,
+ "/ which can happen when a process with a suspend action goes into a readWait,
+ "/ and the suspend action does a thread switch, and the readWait semaphore gets
+ "/ signalled before we come back here. Then the semaphore wakeup will have already
+ "/ place me back into the run state, so I should not go into a suspend below.
+ ^ self.
+ ].
+ state := savedState.
+ ].
+
+ "
+ this is a bit of a kludge: allow someone else to
+ set the state to something like #ioWait etc.
+ In this case, do not set the receiver's state to #suspend.
+ (All of this to enhance the output of the process monitor ...)
+ "
+ (state == #active
+ or:[state == #run
+ or:[aStateSymbol == #stopped]]) ifTrue:[
+ state := aStateSymbol.
+ ].
+ Processor suspend:self
+
+ "Modified: / 30-05-2018 / 13:57:00 / Claus Gittinger"
+! !
+
!Process methodsFor:'thread local storage'!