uasyncio.core: Introduce "trailing _" functions which avoid arg un/packing.

They just take tuple of arguments instead of *args. In most cases, that
will be () singleton.
pull/120/head
Paul Sokolovsky 2016-11-13 14:51:04 +03:00
rodzic 67d8e55dea
commit 02a6625a00
1 zmienionych plików z 8 dodań i 3 usunięć

Wyświetl plik

@ -29,14 +29,19 @@ class EventLoop:
def call_later(self, delay, callback, *args):
self.call_at(time.ticks_add(self.time(), int(delay * 1000)), callback, *args)
def call_later_ms(self, delay, callback, *args):
self.call_at(time.ticks_add(self.time(), delay), callback, *args)
def call_later_ms_(self, delay, callback, args=()):
self.call_at_(time.ticks_add(self.time(), delay), callback, args)
def call_at(self, time, callback, *args):
if __debug__:
log.debug("Scheduling %s", (time, callback, args))
heapq.heappush(self.q, (time, callback, args), True)
def call_at_(self, time, callback, args=()):
if __debug__ and DEBUG:
log.debug("Scheduling %s", (time, callback, args))
heapq.heappush(self.q, (time, callback, args), True)
def wait(self, delay):
# Default wait implementation, to be overriden in subclasses
# with IO scheduling
@ -106,7 +111,7 @@ class EventLoop:
if __debug__:
log.debug("Coroutine finished: %s", cb)
continue
self.call_later_ms(delay, cb, *args)
self.call_later_ms_(delay, cb, args)
def run_until_complete(self, coro):
def _run_and_stop():