예제 #1
0
    def __init__(self, name, postNames, callback, removeNames=None):
        self.notify.debug('__init__: %s, %s, %s' % (name, postNames, callback))
        if removeNames is None:
            removeNames = []

        self.name = name
        self.postNames = makeList(postNames)
        self.removeNames = makeList(removeNames)
        self.callback = callback
        self.waitingOn = set()
        for name in self.postNames:
            if not bboard.has(name):
                eventName = bboard.getEvent(name)
                self.waitingOn.add(eventName)
                self.acceptOnce(eventName, Functor(self._handleEvent,
                                                   eventName))
                continue

        for name in self.removeNames:
            if bboard.has(name):
                eventName = bboard.getRemoveEvent(name)
                self.waitingOn.add(eventName)
                self.acceptOnce(eventName, Functor(self._handleEvent,
                                                   eventName))
                continue

        self._checkDone()
예제 #2
0
 def addExclObjs(cls, *objs):
     for obj in makeList(objs):
         if id(obj) not in cls._ExclObjIds:
             cls._ExclObjs.append(obj)
         cls._ExclObjIds.setdefault(id(obj), 0)
         cls._ExclObjIds[id(obj)] += 1
     cls._SyncMaster.change()
 def addExclObjs(cls, *objs):
     for obj in makeList(objs):
         if id(obj) not in cls._ExclObjIds:
             cls._ExclObjs.append(obj)
         cls._ExclObjIds.setdefault(id(obj), 0)
         cls._ExclObjIds[id(obj)] += 1
     cls._SyncMaster.change()
예제 #4
0
 def removeExclObjs(cls, *objs):
     for obj in makeList(objs):
         assert id(obj) in cls._ExclObjIds
         cls._ExclObjIds[id(obj)] -= 1
         if cls._ExclObjIds[id(obj)] == 0:
             del cls._ExclObjIds[id(obj)]
             cls._ExclObjs.remove(obj)
     cls._SyncMaster.change()
예제 #5
0
    def removeExclObjs(cls, *objs):
        for obj in makeList(objs):
            cls._ExclObjIds[id(obj)] -= 1
            if cls._ExclObjIds[id(obj)] == 0:
                del cls._ExclObjIds[id(obj)]
                cls._ExclObjs.remove(obj)

        cls._SyncMaster.change()
예제 #6
0
    def removeExclObjs(cls, *objs):
        for obj in makeList(objs):
            cls._ExclObjIds[id(obj)] -= 1
            if cls._ExclObjIds[id(obj)] == 0:
                del cls._ExclObjIds[id(obj)]
                cls._ExclObjs.remove(obj)
                continue

        cls._SyncMaster.change()
예제 #7
0
 def typeFreqStr(self):
     s = 'Object Pool: Type Frequencies'
     s += '\n============================='
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             s += '\n%s\t%s' % (count, typ)
     return s
예제 #8
0
 def typeFreqStr(self):
     s  =   'Object Pool: Type Frequencies'
     s += '\n============================='
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             s += '\n%s\t%s' % (count, typ)
     return s
예제 #9
0
 def __init__(self, name, postNames, callback, removeNames=None):
     self.notify.debug('__init__: %s, %s, %s' % (name, postNames, callback))
     if removeNames is None:
         removeNames = []
     self.name = name
     self.postNames = makeList(postNames)
     self.removeNames = makeList(removeNames)
     self.callback = callback
     self.waitingOn = set()
     for name in self.postNames:
         if not bboard.has(name):
             eventName = bboard.getEvent(name)
             self.waitingOn.add(eventName)
             self.acceptOnce(eventName, Functor(self._handleEvent, eventName))
     for name in self.removeNames:
         if bboard.has(name):
             eventName = bboard.getRemoveEvent(name)
             self.waitingOn.add(eventName)
             self.acceptOnce(eventName, Functor(self._handleEvent, eventName))
     self._checkDone()
예제 #10
0
 def printObjsByType(self):
     print('Object Pool: Objects By Type')
     print('\n============================')
     counts = list(set(self._count2types.keys()))
     counts.sort()
     # print types with the smallest number of instances first, in case
     # there's a large group that waits a long time before printing
     #counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print('TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])))
             print(getNumberedTypedSortedString(self._type2objs[typ]))
예제 #11
0
 def printObjsByType(self):
     print('Object Pool: Objects By Type')
     print('\n============================')
     counts = list(set(self._count2types.keys()))
     counts.sort()
     # print types with the smallest number of instances first, in case
     # there's a large group that waits a long time before printing
     #counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print('TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ])))
             print(getNumberedTypedSortedString(self._type2objs[typ]))
예제 #12
0
 def printObjsByType(self, printReferrers = False):
     print 'Object Pool: Objects By Type'
     print '\n============================'
     counts = list(set(self._count2types.keys()))
     counts.sort()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ]))
             if printReferrers:
                 for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]):
                     print line
                 
             print getNumberedTypedSortedString(self._type2objs[typ])
예제 #13
0
 def printObjsByType(self, printReferrers=False):
     print   'Object Pool: Objects By Type'
     print '\n============================'
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ]))
             if printReferrers:
                 for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]):
                     print line
             else:
                 print getNumberedTypedSortedString(self._type2objs[typ])
예제 #14
0
 def printReferrers(self, numEach = 3):
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print '\n\nTYPE: %s' % repr(typ)
             for i in xrange(min(numEach, len(self._type2objs[typ]))):
                 obj = self._type2objs[typ][i]
                 print '\nOBJ: %s\n' % safeRepr(obj)
                 referrers = gc.get_referrers(obj)
                 print '%s REFERRERS:\n' % len(referrers)
                 if len(referrers):
                     print getNumberedTypedString(referrers, maxLen = 80, numPrefix = 'REF')
                     continue
                 print '<No Referrers>'
예제 #15
0
 def printObjsByType(self, printReferrers=False):
     print   'Object Pool: Objects By Type'
     print '\n============================'
     counts = list(set(self._count2types.keys()))
     counts.sort()
     # print types with the smallest number of instances first, in case
     # there's a large group that waits a long time before printing
     #counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print 'TYPE: %s, %s objects' % (repr(typ), len(self._type2objs[typ]))
             if printReferrers:
                 for line in getNumberedTypedSortedStringWithReferrersGen(self._type2objs[typ]):
                     print line
             else:
                 print getNumberedTypedSortedString(self._type2objs[typ])
예제 #16
0
파일: ObjectPool.py 프로젝트: pmp-p/panda3d
 def printReferrers(self, numEach=3):
     """referrers of the first few of each type of object"""
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print "\n\nTYPE: %s" % repr(typ)
             for i in xrange(min(numEach, len(self._type2objs[typ]))):
                 obj = self._type2objs[typ][i]
                 print "\nOBJ: %s\n" % safeRepr(obj)
                 referrers = gc.get_referrers(obj)
                 print "%s REFERRERS:\n" % len(referrers)
                 if len(referrers):
                     print getNumberedTypedString(referrers, maxLen=80, numPrefix="REF")
                 else:
                     print "<No Referrers>"
예제 #17
0
 def printReferrers(self, numEach=3):
     """referrers of the first few of each type of object"""
     counts = list(set(self._count2types.keys()))
     counts.sort()
     counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print('\n\nTYPE: %s' % repr(typ))
             for i in range(min(numEach, len(self._type2objs[typ]))):
                 obj = self._type2objs[typ][i]
                 print('\nOBJ: %s\n' % safeRepr(obj))
                 referrers = gc.get_referrers(obj)
                 print('%s REFERRERS:\n' % len(referrers))
                 if len(referrers):
                     print(getNumberedTypedString(referrers, maxLen=80,
                                                 numPrefix='REF'))
                 else:
                     print('<No Referrers>')
예제 #18
0
 def printObjsByType(self, printReferrers=False):
     print 'Object Pool: Objects By Type'
     print '\n============================'
     counts = list(set(self._count2types.keys()))
     counts.sort()
     # print types with the smallest number of instances first, in case
     # there's a large group that waits a long time before printing
     #counts.reverse()
     for count in counts:
         types = makeList(self._count2types[count])
         for typ in types:
             print 'TYPE: %s, %s objects' % (repr(typ),
                                             len(self._type2objs[typ]))
             if printReferrers:
                 for line in getNumberedTypedSortedStringWithReferrersGen(
                         self._type2objs[typ]):
                     print line
             else:
                 print getNumberedTypedSortedString(self._type2objs[typ])
예제 #19
0
 def _loadSound(self):
     self._sounds = []
     for soundFile in makeList(self._data.soundFile):
         self._sounds.append(loader.loadSfx(soundFile))
예제 #20
0
 def _getMsgName(self, msgId):
     # we might get a list of message names, use the first one
     return makeList(MsgId2Names.get(msgId,
                                     'UNKNOWN MESSAGE: %s' % msgId))[0]
예제 #21
0
 def _loadSound(self):
     self._sounds = []
     for soundFile in makeList(self._data.soundFile):
         self._sounds.append(loader.loadSfx(soundFile))