'From Croquet1.0beta of 11 April 2006 [latest update: #1] on 4 December 2007 at 4:32:26 pm'! !Interpreter methodsFor: 'processes' stamp: 'ar 12/4/2007 16:21'! removeProcess: aProcess fromList: aList "Remove a given process from a linked list. May fail if aProcess is not on the list." | firstLink lastLink nextLink tempLink | firstLink := self fetchPointer: FirstLinkIndex ofObject: aList. lastLink := self fetchPointer: LastLinkIndex ofObject: aList. aProcess == firstLink ifTrue:[ nextLink := self fetchPointer: NextLinkIndex ofObject: aProcess . self storePointer: FirstLinkIndex ofObject: aList withValue: nextLink. aProcess == lastLink ifTrue:[ self storePointer: LastLinkIndex ofObject: aList withValue: self nilObject. ]. ] ifFalse:[ tempLink := firstLink. [tempLink == self nilObject ifTrue:[^self success: false]. "fail" nextLink := self fetchPointer: NextLinkIndex ofObject: tempLink. nextLink == aProcess] whileFalse:[ tempLink := self fetchPointer: NextLinkIndex ofObject: tempLink. ]. nextLink := self fetchPointer: NextLinkIndex ofObject: aProcess. self storePointer: NextLinkIndex ofObject: tempLink withValue: nextLink. aProcess == lastLink ifTrue:[ self storePointer: LastLinkIndex ofObject: aList withValue: tempLink. ]. ]. self storePointer: NextLinkIndex ofObject: aProcess withValue: self nilObject. ! ! !Interpreter methodsFor: 'process primitives' stamp: 'ar 12/4/2007 16:31'! primitiveSuspend "Primitive. Suspend the receiver, aProcess such that it can be executed again by sending #resume. If the given process is not currently running, take it off its corresponding list. The primitive returns the list the receiver was previously on." | process activeProc myList | process := self stackTop. activeProc := self fetchPointer: ActiveProcessIndex ofObject: self schedulerPointer. process == activeProc ifTrue:[ self pop: 1. self push: nilObj. self transferTo: self wakeHighestPriority. ] ifFalse:[ myList := self fetchPointer: MyListIndex ofObject: process. "XXXX Fixme. We should really check whether myList is a kind of LinkedList or not but we can't easily so just do a quick check for nil which is the most common case." myList == self nilObject ifTrue:[^self primitiveFail]. self removeProcess: process fromList: myList. successFlag ifTrue:[ self storePointer: MyListIndex ofObject: process withValue: self nilObject. self pop: 1. self push: myList. ]. ].! !