mainloop cleanup/speedup
[vuplus_dvbapp] / e2reactor.py
index 7caeb7f..4f069f9 100644 (file)
@@ -27,6 +27,7 @@ POLL_DISCONNECTED = (select.POLLHUP | select.POLLERR | select.POLLNVAL)
 class E2SharedPoll:
        def __init__(self):
                self.dict = { }
 class E2SharedPoll:
        def __init__(self):
                self.dict = { }
+               self.eApp = getApplication()
 
        def register(self, fd, eventmask = select.POLLIN | select.POLLERR | select.POLLOUT):
                self.dict[fd] = eventmask
 
        def register(self, fd, eventmask = select.POLLIN | select.POLLERR | select.POLLOUT):
                self.dict[fd] = eventmask
@@ -35,7 +36,7 @@ class E2SharedPoll:
                del self.dict[fd]
        
        def poll(self, timeout = None):
                del self.dict[fd]
        
        def poll(self, timeout = None):
-               r = getApplication().poll(timeout, self.dict)
+               r = self.eApp.poll(timeout, self.dict)
                return r
 
 poller = E2SharedPoll()
                return r
 
 poller = E2SharedPoll()
@@ -58,7 +59,8 @@ class PollReactor(posixbase.PosixReactorBase):
                else:
                        if selectables.has_key(fd): del selectables[fd]
                
                else:
                        if selectables.has_key(fd): del selectables[fd]
                
-               getApplication().interruptPoll()
+               
+               poller.eApp.interruptPoll()
 
        def _dictRemove(self, selectable, mdict):
                try:
 
        def _dictRemove(self, selectable, mdict):
                try:
@@ -188,7 +190,7 @@ class PollReactor(posixbase.PosixReactorBase):
                        self._disconnectSelectable(selectable, why, inRead)
 
        def callLater(self, *args, **kwargs):
                        self._disconnectSelectable(selectable, why, inRead)
 
        def callLater(self, *args, **kwargs):
-               getApplication().interruptPoll()
+               poller.eApp.interruptPoll()
                return posixbase.PosixReactorBase.callLater(self, *args, **kwargs)
 
 def install():
                return posixbase.PosixReactorBase.callLater(self, *args, **kwargs)
 
 def install():