def beginBarrier(self, name, avIds, timeout, callback): # Begins waiting for a set of avatars. When all avatars in # the list have reported back in or the callback has expired, # calls the indicated callback with the list of avatars that # made it through. There may be multiple barriers waiting # simultaneously on different lists of avatars, although they # should have different names. from otp.ai import Barrier context = self.__nextBarrierContext # We assume the context number is passed as a uint16. self.__nextBarrierContext = (self.__nextBarrierContext + 1) & 0xffff assert self.notify.debug('beginBarrier(%s, %s, %s, %s)' % (context, name, avIds, timeout)) if avIds: barrier = Barrier.Barrier(name, self.uniqueName(name), avIds, timeout, doneFunc=PythonUtil.Functor( self.__barrierCallback, context, callback)) self.__barriers[context] = barrier # Send the context number to each involved client. self.sendUpdate("setBarrierData", [self.getBarrierData()]) else: # No avatars; just call the callback immediately. callback(avIds) return context
def beginBarrier(self, name, avIds, timeout, callback): from otp.ai import Barrier context = self.__nextBarrierContext self.__nextBarrierContext = self.__nextBarrierContext + 1 & 65535 if avIds: barrier = Barrier.Barrier(name, self.uniqueName(name), avIds, timeout, doneFunc=PythonUtil.Functor( self.__barrierCallback, context, callback)) self.__barriers[context] = barrier self.sendUpdate('setBarrierData', [self.__getBarrierData()]) else: callback(avIds) return context