From f2d6c73ccb814cf116d25441b8905c8f29e75cef Mon Sep 17 00:00:00 2001 From: John Loehrlein Date: Fri, 21 Apr 2006 18:39:25 +0000 Subject: [PATCH] Optional sleep scheme. Tested and can handle up to 4 clients at once without any starving. Client with focus will not run as fast, obivously. --- direct/src/showbase/ShowBase.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 93725c8fd2..cf1ccb291e 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -263,6 +263,15 @@ class ShowBase(DirectObject.DirectObject): sleepTime = self.config.GetFloat('client-sleep', 0.0) self.clientSleep = 0.0 self.setSleep(sleepTime) + + # Extra sleep for running 4+ clients on a single machine + # adds a sleep right after the main render in igloop + # tends to even out the frame rate and keeps it from going + # to zero in the out of focus windows + if base.config.GetBool('multi-sleep', 1): + self.multiClientSleep = 1 + else: + self.multiClientSleep = 0 # Offscreen buffer viewing utility. self.bufferViewer = BufferViewer() @@ -1286,6 +1295,8 @@ class ShowBase(DirectObject.DirectObject): self.graphicsEngine.renderFrame() if self.clusterSyncFlag: self.graphicsEngine.syncFrame() + if self.multiClientSleep: + time.sleep(0) # We clear the text buffer for the onScreenDebug as soon # as we reasonably can after the renderFrame().