[BUG][FIX?] spawnNewProcessIfNeeded

Lex Spoon lex at cc.gatech.edu
Sun Mar 5 14:32:50 UTC 2000


I'm not completely sure how to fix this, but perhaps it is obvious to
someone else.  The goal is that if a background thread has a fault, then
no new UI process should be started.  However, if the UI thread has a
fault, then the UI thread is now dead and thus a new UI process *should*
be started.

The current way to decide this is literally, wait 1 second and see if
the UI thread goes througha t least one loop during this interval.  This
is incorrect, because in extreme circumstances 1 iteration of the
Morphic UI really can take longer than 1 second.  Furthermore, it's
annoying in the common case, becasue you have to wait a full 1 second
before the UI comes back to life.

Below is an attempt to fix it.  The spawnNewProcessIfNeeded is now given
a parameter, which is the process which just got axed.  However, I'm not
completely sure if activeProcess is exactly what I think it is....



Lex



====

'From Squeak2.8alpha of 27 February 2000 [latest update: #1899] on 5 March 2000 at 2:31:51 pm'!
"Change Set:		spawnIfNeeded
Date:			5 March 2000
Author:			Lex Spoon

Attempts to make spawnNewProcessIfNeeded both faster and (hopefully) correct"!


!ApplescriptError class methodsFor: 'as yet unclassified' stamp: 'ls 3/5/2000 14:22'!
open: aSyntaxError
	"Answer a standard system view whose model is an instance of me."
	| topView |
	<primitive: 19> "Simulation guard"
	World ifNotNil:
		[self buildMorphicViewOn: aSyntaxError.
		Project current spawnNewProcessIfThisIsUI: Processor activeProcess.
		^ Processor activeProcess suspend].
	topView _ self buildMVCViewOn: aSyntaxError.
	topView controller openNoTerminateDisplayAt: Display extent // 2.
	Cursor normal show.
	Processor activeProcess suspend.
! !


!Debugger methodsFor: 'initialize' stamp: 'ls 3/5/2000 14:20'!
openFullNoSuspendLabel: aString
	"Create and schedule a full debugger with the given label. Do not terminate the current active process."

	| topView |
	Smalltalk isMorphic ifTrue:
		[self openFullMorphicLabel: aString.
		^ Project current spawnNewProcessIfThisIsUI: interruptedProcess].
	topView _ self buildMVCDebuggerViewLabel: aString minSize: 300 at 200.
	topView controller openNoTerminate.
	^ topView
! !

!Debugger methodsFor: 'initialize' stamp: 'ls 3/5/2000 14:21'!
openNotifierContents: msgString label: label
	"Create and schedule a notifier view with the given label and message. A notifier view shows just the message or the first several lines of the stack, with a menu that allows the user to open a full debugger if so desired."
	"NOTE: When this method returns, a new process has been scheduled to run the windows, and thus this notifier, but the previous active porcess has not been suspended.  The sender will do this."
	| msg topView p |
	Sensor flushKeyboard.
	(label beginsWith: 'Space is low')
		ifTrue: [msg _ self lowSpaceChoices, msgString]
		ifFalse: [msg _ msgString].

	World ifNotNil:
		[self buildMorphicNotifierLabelled: label message: msg.
		^ Project current spawnNewProcessIfThisIsUI: interruptedProcess].

	Display fullScreen.
	Cursor normal show.
	topView _ self buildMVCNotifierViewLabel: label message: msg minSize: 350@((14 * 5) + 16 + self optionalButtonHeight).
	ScheduledControllers activeController
		ifNil: [p _ Display boundingBox center]
		ifNotNil: [p _ ScheduledControllers activeController view displayBox center].
	topView controller openNoTerminateDisplayAt: (p max: (200 at 60)).
	^ topView! !


!Project methodsFor: 'active process' stamp: 'ls 3/5/2000 14:29'!
spawnNewProcessIfThisIsUI: suspendedProcess

	world isMorph ifFalse: [^self spawnNewProcess].	"does this ever happen?"
	self activeProcess == suspendedProcess ifTrue: [
		"Transcript show: 'spawning'; cr."
		self spawnNewProcess ] 
	ifFalse: [ "Transcript show: 'not spawning'; cr" ].! !


!SyntaxError class methodsFor: 'instance creation' stamp: 'ls 3/5/2000 14:22'!
open: aSyntaxError
	"Answer a standard system view whose model is an instance of me."
	| topView |
	<primitive: 19> "Simulation guard"
	World ifNotNil:
		[self buildMorphicViewOn: aSyntaxError.
		Project current spawnNewProcessIfThisIsUI: Processor activeProcess.
		^ Processor activeProcess suspend].
	topView _ self buildMVCViewOn: aSyntaxError.
	topView controller openNoTerminateDisplayAt: Display extent // 2.
	Cursor normal show.
	Processor activeProcess suspend.
! !


Project removeSelector: #spawnNewProcessIfNeeded!





More information about the Squeak-dev mailing list