From 85702cf2f88f6a0e53510848e6c2e53a29ec6755 Mon Sep 17 00:00:00 2001 From: David Rose Date: Sat, 19 Dec 2009 06:05:44 +0000 Subject: [PATCH] flushTask in its own thread --- direct/src/distributed/ServerRepository.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/direct/src/distributed/ServerRepository.py b/direct/src/distributed/ServerRepository.py index 9f9a646cfb..8352951e19 100644 --- a/direct/src/distributed/ServerRepository.py +++ b/direct/src/distributed/ServerRepository.py @@ -94,6 +94,11 @@ class ServerRepository: 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) @@ -106,7 +111,8 @@ class ServerRepository: self.needsFlush = set() collectTcpInterval = ConfigVariableDouble('collect-tcp-interval').getValue() - taskMgr.doMethodLater(collectTcpInterval, self.flushTask, 'flushTask') + taskMgr.doMethodLater(collectTcpInterval, self.flushTask, 'flushTask', + taskChain = 'flushTask') # A dictionary of connection -> Client object, tracking all of # the clients we currently have connected. @@ -142,9 +148,10 @@ class ServerRepository: collect-tcp is set true (if this is false, messages are sent immediately and do not require periodic flushing). """ - for client in self.needsFlush: - client.connection.flush() + flush = self.needsFlush self.needsFlush = set() + for client in flush: + client.connection.flush() return task.again