diff options
| author | Damien George <damien@micropython.org> | 2022-04-20 17:20:07 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2022-04-22 16:37:02 +1000 |
| commit | caaff940a265bd30cca5a271b49e7addaf05ef53 (patch) | |
| tree | 7413f84e38feee120173b6ea9d65ed3f3aae79f4 /extmod/uasyncio/lock.py | |
| parent | 28e7e15c0ad03f406cc5214f22d9a90a560f65c4 (diff) | |
extmod/uasyncio: Rename and merge TaskQueue push/pop methods.
These are internal names and can be safely renamed without affecting user
code. push_sorted() and push_head() are merged into a single push()
method, which is already how the C version is implemented. pop_head() is
simply renamed to pop().
The changes are:
- q.push_sorted(task, t) -> q.push(task, t)
- q.push_head(task) -> q.push(task)
- q.pop_head() -> q.pop()
The shorter names and removal of push_head() leads to a code size reduction
of between 40 and 64 bytes on bare-metal targets.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'extmod/uasyncio/lock.py')
| -rw-r--r-- | extmod/uasyncio/lock.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/extmod/uasyncio/lock.py b/extmod/uasyncio/lock.py index bddca295b..f50213d7c 100644 --- a/extmod/uasyncio/lock.py +++ b/extmod/uasyncio/lock.py @@ -22,8 +22,8 @@ class Lock: raise RuntimeError("Lock not acquired") if self.waiting.peek(): # Task(s) waiting on lock, schedule next Task - self.state = self.waiting.pop_head() - core._task_queue.push_head(self.state) + self.state = self.waiting.pop() + core._task_queue.push(self.state) else: # No Task waiting so unlock self.state = 0 @@ -31,7 +31,7 @@ class Lock: async def acquire(self): if self.state != 0: # Lock unavailable, put the calling Task on the waiting queue - self.waiting.push_head(core.cur_task) + self.waiting.push(core.cur_task) # Set calling task's data to the lock's queue so it can be removed if needed core.cur_task.data = self.waiting try: |
