mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 09:28:13 +00:00
trezor.loop: support re-using Sleep and Wait objects
This commit is contained in:
parent
b8af656e0a
commit
bf878ff15e
@ -159,10 +159,11 @@ class Sleep(Syscall):
|
||||
'''
|
||||
|
||||
def __init__(self, delay_us):
|
||||
self.deadline = utime.ticks_add(utime.ticks_us(), delay_us)
|
||||
self.delay_us = delay_us
|
||||
|
||||
def handle(self, task):
|
||||
schedule_task(task, self.deadline, self.deadline)
|
||||
deadline = utime.ticks_add(utime.ticks_us(), self.delay_us)
|
||||
schedule_task(task, deadline, deadline)
|
||||
|
||||
|
||||
class Select(Syscall):
|
||||
@ -248,12 +249,13 @@ class Wait(Syscall):
|
||||
self.children = children
|
||||
self.wait_for = wait_for
|
||||
self.exit_others = exit_others
|
||||
self.scheduled = []
|
||||
self.finished = []
|
||||
self.scheduled = None
|
||||
self.finished = None
|
||||
self.callback = None
|
||||
|
||||
def handle(self, task):
|
||||
self.callback = task
|
||||
self.finished = []
|
||||
self.scheduled = [self._wait(c) for c in self.children]
|
||||
for ct in self.scheduled:
|
||||
schedule_task(ct)
|
||||
|
Loading…
Reference in New Issue
Block a user