kopia lustrzana https://github.com/micropython/micropython-lib
uasyncio.core: Optimize for syscalls with single args.
Avoids allocating argument tuples.pull/59/merge
rodzic
4f36827a6c
commit
f9eed2340d
|
@ -71,8 +71,8 @@ class EventLoop:
|
||||||
ret = cb.send(*args)
|
ret = cb.send(*args)
|
||||||
if __debug__:
|
if __debug__:
|
||||||
log.debug("Coroutine %s yield result: %s", cb, ret)
|
log.debug("Coroutine %s yield result: %s", cb, ret)
|
||||||
if isinstance(ret, SysCall):
|
if isinstance(ret, SysCall1):
|
||||||
arg = ret.args[0]
|
arg = ret.arg
|
||||||
if isinstance(ret, Sleep):
|
if isinstance(ret, Sleep):
|
||||||
delay = arg
|
delay = arg
|
||||||
elif isinstance(ret, IORead):
|
elif isinstance(ret, IORead):
|
||||||
|
@ -121,22 +121,28 @@ class SysCall:
|
||||||
def handle(self):
|
def handle(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
class Sleep(SysCall):
|
# Optimized syscall with 1 arg
|
||||||
|
class SysCall1(SysCall):
|
||||||
|
|
||||||
|
def __init__(self, arg):
|
||||||
|
self.arg = arg
|
||||||
|
|
||||||
|
class Sleep(SysCall1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class StopLoop(SysCall):
|
class StopLoop(SysCall1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class IORead(SysCall):
|
class IORead(SysCall1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class IOWrite(SysCall):
|
class IOWrite(SysCall1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class IOReadDone(SysCall):
|
class IOReadDone(SysCall1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class IOWriteDone(SysCall):
|
class IOWriteDone(SysCall1):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue