Beispiel #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()
Beispiel #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()
Beispiel #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()
Beispiel #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()
    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()
Beispiel #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
 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
Beispiel #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()
Beispiel #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]))
Beispiel #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]))
Beispiel #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])
Beispiel #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])
Beispiel #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>'
 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])
Beispiel #16
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 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>"
Beispiel #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>')
 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])
Beispiel #19
0
 def _loadSound(self):
     self._sounds = []
     for soundFile in makeList(self._data.soundFile):
         self._sounds.append(loader.loadSfx(soundFile))
Beispiel #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]
Beispiel #21
0
 def _loadSound(self):
     self._sounds = []
     for soundFile in makeList(self._data.soundFile):
         self._sounds.append(loader.loadSfx(soundFile))