'From Cuis 1.0 of 6 March 2009 [latest update: #5989] on 24 March 2009 at 10:25:11 am'!

!OldWorldState methodsFor: 'update cycle' stamp: 'al 3/24/2009 10:24'!
interCyclePause: milliSecs
	"delay enough that the previous cycle plus the amount of delay will equal milliSecs.  If the cycle is already expensive, then no delay occurs.  However, if the system is idly waiting for interaction from the user, the method will delay for a proportionally long time and cause the overall CPU usage of Squeak to be low."

	| currentTime wait |
	Preferences serverMode
		ifFalse: [
			(lastCycleTime notNil and: [CanSurrenderToOS ~~ false]) ifTrue: [ 
				currentTime _ Time millisecondClockValue.
				wait _ lastCycleTime + milliSecs - currentTime.
		 		(wait > 0 and: [ wait <= milliSecs ] )
				ifTrue: [
					(Delay forMilliseconds: wait) wait ] ] ]
		ifTrue: [ (Delay forMilliseconds: 50) wait ].

	lastCycleTime _  Time millisecondClockValue.
	CanSurrenderToOS _ true.! !


!Preferences class methodsFor: 'standard queries' stamp: 'al 7/31/2007 16:17'!
serverMode
	^ self
		valueOfFlag: #serverMode
		ifAbsent: [false]! !

