From f7454f850feaeef7f567e434205ad648192ba01b Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 21 Apr 2022 13:17:33 +1000 Subject: extmod/uasyncio: Make Python Task match C version with use of asserts. This helps to catch bugs when a Task is put on more than one pairing heap. Signed-off-by: Damien George --- extmod/uasyncio/task.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'extmod/uasyncio/task.py') diff --git a/extmod/uasyncio/task.py b/extmod/uasyncio/task.py index d77516490..94768b95a 100644 --- a/extmod/uasyncio/task.py +++ b/extmod/uasyncio/task.py @@ -100,10 +100,10 @@ class TaskQueue: return self.heap def push_sorted(self, v, key): + assert v.ph_child is None + assert v.ph_next is None v.data = None v.ph_key = key - v.ph_child = None - v.ph_next = None self.heap = ph_meld(v, self.heap) def push_head(self, v): @@ -111,7 +111,9 @@ class TaskQueue: def pop_head(self): v = self.heap - self.heap = ph_pairing(self.heap.ph_child) + assert v.ph_next is None + self.heap = ph_pairing(v.ph_child) + v.ph_child = None return v def remove(self, v): -- cgit v1.2.3