mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
added job-manager-timeslice config
This commit is contained in:
parent
6b968ee0ee
commit
5f07d8f5da
@ -1,6 +1,7 @@
|
|||||||
from direct.directnotify.DirectNotifyGlobal import directNotify
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
||||||
from direct.task.TaskManagerGlobal import taskMgr
|
from direct.task.TaskManagerGlobal import taskMgr
|
||||||
from direct.showbase.Job import Job
|
from direct.showbase.Job import Job
|
||||||
|
from direct.showbase.PythonUtil import getBase
|
||||||
|
|
||||||
class JobManager:
|
class JobManager:
|
||||||
"""
|
"""
|
||||||
@ -12,12 +13,8 @@ class JobManager:
|
|||||||
|
|
||||||
# there's one task for the JobManager, all jobs run in this task
|
# there's one task for the JobManager, all jobs run in this task
|
||||||
TaskName = 'jobManager'
|
TaskName = 'jobManager'
|
||||||
# run for 1/2 millisecond per frame by default
|
|
||||||
DefTimeslice = (1./1000.) * .5
|
|
||||||
|
|
||||||
def __init__(self, timeslice=None):
|
def __init__(self, timeslice=None):
|
||||||
if timeslice is None:
|
|
||||||
timeslice = JobManager.DefTimeslice
|
|
||||||
# how long do we run per frame
|
# how long do we run per frame
|
||||||
self._timeslice = timeslice
|
self._timeslice = timeslice
|
||||||
# store the jobs in these structures to allow fast lookup by various keys
|
# store the jobs in these structures to allow fast lookup by various keys
|
||||||
@ -116,8 +113,14 @@ class JobManager:
|
|||||||
job._pstats.stop()
|
job._pstats.stop()
|
||||||
|
|
||||||
# how long should we run per frame?
|
# 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):
|
def getTimeslice(self):
|
||||||
|
if self._timeslice:
|
||||||
return self._timeslice
|
return self._timeslice
|
||||||
|
return self.getDefaultTimeslice()
|
||||||
def setTimeslice(self, timeslice):
|
def setTimeslice(self, timeslice):
|
||||||
self._timeslice = timeslice
|
self._timeslice = timeslice
|
||||||
|
|
||||||
@ -131,7 +134,7 @@ class JobManager:
|
|||||||
if len(self._pri2jobId2job):
|
if len(self._pri2jobId2job):
|
||||||
#assert self.notify.debugCall()
|
#assert self.notify.debugCall()
|
||||||
# figure out how long we can run
|
# figure out how long we can run
|
||||||
endT = globalClock.getRealTime() + (self._timeslice * .9)
|
endT = globalClock.getRealTime() + (self.getTimeslice() * .9)
|
||||||
while True:
|
while True:
|
||||||
if self._jobIdGenerator is None:
|
if self._jobIdGenerator is None:
|
||||||
# round-robin the jobs, giving high-priority jobs more timeslices
|
# round-robin the jobs, giving high-priority jobs more timeslices
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user