faster tasks and network updates from objects

This commit is contained in:
Zachary Pavlov 2007-10-16 23:49:18 +00:00
parent 2a3d4d0934
commit a20301a2b5
3 changed files with 12 additions and 14 deletions

View File

@ -329,7 +329,9 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns):
def sendUpdate(self, fieldName, args = []): def sendUpdate(self, fieldName, args = []):
assert self.notify.debugStateCall(self) assert self.notify.debugStateCall(self)
if self.air: if self.air:
self.air.sendUpdate(self, fieldName, args) dg = self.dclass.aiFormatUpdate(
fieldName, self.doId, self.doId, self.air.ourChannel, args)
self.air.sendDatagram(dg)
def GetPuppetConnectionChannel(self, doId): def GetPuppetConnectionChannel(self, doId):
return doId + (1L << 32) return doId + (1L << 32)

View File

@ -3050,12 +3050,12 @@ if __debug__:
def quickProfile(name="unnamed"): def quickProfile(name="unnamed"):
def profileDecorator(f): def profileDecorator(f):
if(not base.config.GetBool("use-profiler",0)): if(not config.GetBool("use-profiler",0)):
return f return f
def _profiled(*args, **kArgs): def _profiled(*args, **kArgs):
# must do this in here because we don't have base/simbase # must do this in here because we don't have base/simbase
# at the time that PythonUtil is loaded # at the time that PythonUtil is loaded
if(not base.config.GetBool("profile-debug",0)): if(not config.GetBool("profile-debug",0)):
#dumb timings #dumb timings
st=globalClock.getRealTime() st=globalClock.getRealTime()
f(*args,**kArgs) f(*args,**kArgs)

View File

@ -410,10 +410,8 @@ class TaskManager:
def hasTaskNamed(self, taskName): def hasTaskNamed(self, taskName):
# TODO: check pending task list # TODO: check pending task list
# Get the tasks with this name # Get the tasks with this name
tasks = self.nameDict.get(taskName)
# If we found some, see if any of them are still active (not removed) # If we found some, see if any of them are still active (not removed)
if tasks: for task in self.nameDict.get(taskName, []):
for task in tasks:
if not task._removed: if not task._removed:
return 1 return 1
# Didnt find any, return 0 # Didnt find any, return 0
@ -422,18 +420,16 @@ class TaskManager:
def getTasksNamed(self, taskName): def getTasksNamed(self, taskName):
# TODO: check pending tasks # TODO: check pending tasks
# Get the tasks with this name # Get the tasks with this name
tasks = self.nameDict.get(taskName, []) return [task for task in self.nameDict.get(taskName, []) #grab all tasks with name
# Filter out the tasks that have been removed if not task._removed] #filter removed tasks
if tasks:
tasks = filter(lambda task: not task._removed, tasks)
return tasks
def __doLaterFilter(self): def __doLaterFilter(self):
# Filter out all the tasks that have been removed like a mark and # Filter out all the tasks that have been removed like a mark and
# sweep garbage collector. Returns the number of tasks that have # sweep garbage collector. Returns the number of tasks that have
# been removed Warning: this creates an entirely new doLaterList. # been removed Warning: this creates an entirely new doLaterList.
oldLen = len(self.__doLaterList) oldLen = len(self.__doLaterList)
self.__doLaterList = filter(lambda task: not task._removed, self.__doLaterList) self.__doLaterList = [task for task in self.__doLaterList #grab all tasks with name
if not task._removed] #filter removed tasks
# Re heapify to maintain ordering after filter # Re heapify to maintain ordering after filter
heapify(self.__doLaterList) heapify(self.__doLaterList)
newLen = len(self.__doLaterList) newLen = len(self.__doLaterList)