From 5f07d8f5da0ca9e688270fd9ac41df4fd119dcc4 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Fri, 20 Apr 2007 07:50:17 +0000 Subject: [PATCH] added job-manager-timeslice config --- direct/src/showbase/JobManager.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/direct/src/showbase/JobManager.py b/direct/src/showbase/JobManager.py index 37efbdc033..7deede9c09 100755 --- a/direct/src/showbase/JobManager.py +++ b/direct/src/showbase/JobManager.py @@ -1,6 +1,7 @@ from direct.directnotify.DirectNotifyGlobal import directNotify from direct.task.TaskManagerGlobal import taskMgr from direct.showbase.Job import Job +from direct.showbase.PythonUtil import getBase class JobManager: """ @@ -12,12 +13,8 @@ class JobManager: # there's one task for the JobManager, all jobs run in this task TaskName = 'jobManager' - # run for 1/2 millisecond per frame by default - DefTimeslice = (1./1000.) * .5 def __init__(self, timeslice=None): - if timeslice is None: - timeslice = JobManager.DefTimeslice # how long do we run per frame self._timeslice = timeslice # store the jobs in these structures to allow fast lookup by various keys @@ -116,8 +113,14 @@ class JobManager: job._pstats.stop() # how long should we run per frame? + @staticmethod + def getDefaultTimeslice(): + # run for 1/2 millisecond per frame by default + return getBase().config.GetFloat('job-manager-timeslice', (1./1000.) * .5) def getTimeslice(self): - return self._timeslice + if self._timeslice: + return self._timeslice + return self.getDefaultTimeslice() def setTimeslice(self, timeslice): self._timeslice = timeslice @@ -131,7 +134,7 @@ class JobManager: if len(self._pri2jobId2job): #assert self.notify.debugCall() # figure out how long we can run - endT = globalClock.getRealTime() + (self._timeslice * .9) + endT = globalClock.getRealTime() + (self.getTimeslice() * .9) while True: if self._jobIdGenerator is None: # round-robin the jobs, giving high-priority jobs more timeslices