From 6a39b5ec60f7a96988c1a7c2c61d19f34c1ed261 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Tue, 8 Oct 2013 17:11:30 -0600 Subject: [PATCH] Add (de)allocateChannel functions to AIR. --- .../distributed/AstronInternalRepository.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/direct/src/distributed/AstronInternalRepository.py b/direct/src/distributed/AstronInternalRepository.py index 63f858c7fc..b6e2d4aafc 100644 --- a/direct/src/distributed/AstronInternalRepository.py +++ b/direct/src/distributed/AstronInternalRepository.py @@ -32,7 +32,7 @@ class AstronInternalRepository(ConnectionRepository): maxChannels = self.config.GetInt('air-channel-allocation', 1000000) self.channelAllocator = UniqueIdAllocator(baseChannel, baseChannel+maxChannels-1) - self.ourChannel = self.channelAllocator.allocate() + self.ourChannel = self.allocateChannel() self.eventLogId = self.config.GetString('eventlog-id', 'AIR:%d' % self.ourChannel) self.eventSocket = None @@ -46,6 +46,23 @@ class AstronInternalRepository(ConnectionRepository): self.readDCFile(dcFileNames) + def allocateChannel(self): + """ + Allocate an unused channel out of this AIR's configured channel space. + + This is also used to allocate IDs for DistributedObjects, since those + occupy a channel. + """ + + return self.channelAllocator.allocate() + + def deallocateChannel(self, channel): + """ + Return the previously-allocated channel back to the allocation pool. + """ + + self.channelAllocator.free(channel) + def setEventLogHost(self, host, port=7197): """ Set the target host for Event Logger messaging. This should be pointed