コード例 #1
0
    def __init__(self, appRunner, taskChain='default'):
        self.globalLock.acquire()
        try:
            self.uniqueId = PackageInstaller.nextUniqueId
            PackageInstaller.nextUniqueId += 1
        finally:
            self.globalLock.release()

        self.appRunner = appRunner
        self.taskChain = taskChain

        # If we're to be running on an asynchronous task chain, and
        # the task chain hasn't yet been set up already, create the
        # default parameters now.
        if taskChain != 'default' and not taskMgr.hasTaskChain(self.taskChain):
            taskMgr.setupTaskChain(self.taskChain,
                                   numThreads=1,
                                   threadPriority=TPLow)

        self.callbackLock = Lock()
        self.calledDownloadStarted = False
        self.calledDownloadFinished = False

        # A list of all packages that have been added to the
        # installer.
        self.packageLock = RLock()
        self.packages = []
        self.state = self.S_initial

        # A list of packages that are waiting for their desc files.
        self.needsDescFile = []
        self.descFileTask = None

        # A list of packages that are waiting to be downloaded and
        # installed.
        self.needsDownload = []
        self.downloadTask = None

        # A list of packages that were already done at the time they
        # were passed to addPackage().
        self.earlyDone = []

        # A list of packages that have been successfully installed, or
        # packages that have failed.
        self.done = []
        self.failed = []

        # This task is spawned on the default task chain, to update
        # the status during the download.
        self.progressTask = None

        self.accept('PackageInstaller-%s-allHaveDesc' % self.uniqueId,
                    self.__allHaveDesc)
        self.accept('PackageInstaller-%s-packageStarted' % self.uniqueId,
                    self.__packageStarted)
        self.accept('PackageInstaller-%s-packageDone' % self.uniqueId,
                    self.__packageDone)
コード例 #2
0
    def __init__(self, appRunner, taskChain = 'default'):
        self.globalLock.acquire()
        try:
            self.uniqueId = PackageInstaller.nextUniqueId
            PackageInstaller.nextUniqueId += 1
        finally:
            self.globalLock.release()

        self.appRunner = appRunner
        self.taskChain = taskChain

        # If we're to be running on an asynchronous task chain, and
        # the task chain hasn't yet been set up already, create the
        # default parameters now.
        if taskChain != 'default' and not taskMgr.hasTaskChain(self.taskChain):
            taskMgr.setupTaskChain(self.taskChain, numThreads = 1,
                                   threadPriority = TPLow)

        self.callbackLock = Lock()
        self.calledDownloadStarted = False
        self.calledDownloadFinished = False

        # A list of all packages that have been added to the
        # installer.
        self.packageLock = RLock()
        self.packages = []
        self.state = self.S_initial

        # A list of packages that are waiting for their desc files.
        self.needsDescFile = []
        self.descFileTask = None

        # A list of packages that are waiting to be downloaded and
        # installed.
        self.needsDownload = []
        self.downloadTask = None

        # A list of packages that were already done at the time they
        # were passed to addPackage().
        self.earlyDone = []

        # A list of packages that have been successfully installed, or
        # packages that have failed.
        self.done = []
        self.failed = []

        # This task is spawned on the default task chain, to update
        # the status during the download.
        self.progressTask = None

        self.accept('PackageInstaller-%s-allHaveDesc' % self.uniqueId,
                    self.__allHaveDesc)
        self.accept('PackageInstaller-%s-packageStarted' % self.uniqueId,
                    self.__packageStarted)
        self.accept('PackageInstaller-%s-packageDone' % self.uniqueId,
                    self.__packageDone)
コード例 #3
0
ファイル: OTPBase.py プロジェクト: NoraTheGamer/StrideMods
    def __init__(self, windowType=None):
        ShowBase.__init__(self, windowType=windowType)
        self.idTags = config.GetBool('want-id-tags', 0)
        if not self.idTags:
            del self.idTags
        self.wantNametags = self.config.GetBool('want-nametags', 1)
        self.wantDynamicShadows = 1
        self.stereoEnabled = False
        self.whiteList = None

        if config.GetBool('want-whitelist', True):
            self.whiteList = WhiteList.WhiteList()
            self.whiteList.setWords(WhiteListData.WHITELIST)

            if config.GetBool('want-sequence-list', True):
                self.whiteList.setSequenceList(SequenceListData.SEQUENCES)

        base.cam.node().setCameraMask(OTPRender.MainCameraBitmask)
        taskMgr.setupTaskChain('net',
                               numThreads=1,
                               frameBudget=0.001,
                               threadPriority=TPLow)
コード例 #4
0
    def __init__(self,
                 tcpPort,
                 serverAddress=None,
                 udpPort=None,
                 dcFileNames=None,
                 threadedNet=None):
        if threadedNet is None:
            # Default value.
            threadedNet = ConfigVariableBool('threaded-net', False).value

        # Set up networking interfaces.
        numThreads = 0
        if threadedNet:
            numThreads = 1
        self.qcm = QueuedConnectionManager()
        self.qcl = QueuedConnectionListener(self.qcm, numThreads)
        self.qcr = QueuedConnectionReader(self.qcm, numThreads)
        self.cw = ConnectionWriter(self.qcm, numThreads)

        taskMgr.setupTaskChain('flushTask')
        if threadedNet:
            taskMgr.setupTaskChain('flushTask',
                                   numThreads=1,
                                   threadPriority=TPLow,
                                   frameSync=True)

        self.tcpRendezvous = self.qcm.openTCPServerRendezvous(
            serverAddress or '', tcpPort, 10)
        self.qcl.addConnection(self.tcpRendezvous)
        taskMgr.add(self.listenerPoll, "serverListenerPollTask")
        taskMgr.add(self.readerPollUntilEmpty, "serverReaderPollTask")
        taskMgr.add(self.clientHardDisconnectTask, "clientHardDisconnect")

        # A set of clients that have recently been written to and may
        # need to be flushed.
        self.needsFlush = set()

        collectTcpInterval = ConfigVariableDouble(
            'collect-tcp-interval').getValue()
        taskMgr.doMethodLater(collectTcpInterval,
                              self.flushTask,
                              'flushTask',
                              taskChain='flushTask')

        # A dictionary of connection -> Client object, tracking all of
        # the clients we currently have connected.
        self.clientsByConnection = {}

        # A similar dictionary of doIdBase -> Client object, indexing
        # by the client's doIdBase number instead.
        self.clientsByDoIdBase = {}

        # A dictionary of zoneId -> set([Client]), listing the clients
        # that have an interest in each zoneId.
        self.zonesToClients = {}

        # A dictionary of zoneId -> set([Object]), listing the
        # distributed objects assigned to each zone, globally.
        self.objectsByZoneId = {}

        # The number of doId's to assign to each client.  Must remain
        # constant during server lifetime.
        self.doIdRange = _server_doid_range.value

        # An allocator object that assigns the next doIdBase to each
        # client.
        self.idAllocator = UniqueIdAllocator(0, 0xffffffff // self.doIdRange)

        self.dcFile = DCFile()
        self.dcSuffix = ''
        self.readDCFile(dcFileNames)
コード例 #5
0
import __builtin__
import os

from panda3d.core import loadPrcFile

if os.path.exists('config/general.prc'):
    loadPrcFile('config/general.prc')

from panda3d.direct import get_config_showbase
from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.task.TaskManagerGlobal import taskMgr as task_mgr

__builtin__.config = get_config_showbase()
__builtin__.task_mgr = task_mgr
__builtin__.task_chain = task_mgr.setupTaskChain('mainloop-taskchain',
                                                 numThreads=4,
                                                 frameSync=False)

from realtime import io, types, clientagent, messagedirector, \
    stateserver, database

notify = directNotify.newCategory('Main')
notify.setInfo(True)


def setup_component(cls, *args, **kwargs):
    notify.info('Starting component: %s...' % (cls.__name__))

    component = cls(*args, **kwargs)
    component.setup()