mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 09:00:23 +08:00
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 <damien@micropython.org>
This commit is contained in:
parent
8631753ff4
commit
f7454f850f
@ -100,10 +100,10 @@ class TaskQueue:
|
|||||||
return self.heap
|
return self.heap
|
||||||
|
|
||||||
def push_sorted(self, v, key):
|
def push_sorted(self, v, key):
|
||||||
|
assert v.ph_child is None
|
||||||
|
assert v.ph_next is None
|
||||||
v.data = None
|
v.data = None
|
||||||
v.ph_key = key
|
v.ph_key = key
|
||||||
v.ph_child = None
|
|
||||||
v.ph_next = None
|
|
||||||
self.heap = ph_meld(v, self.heap)
|
self.heap = ph_meld(v, self.heap)
|
||||||
|
|
||||||
def push_head(self, v):
|
def push_head(self, v):
|
||||||
@ -111,7 +111,9 @@ class TaskQueue:
|
|||||||
|
|
||||||
def pop_head(self):
|
def pop_head(self):
|
||||||
v = self.heap
|
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
|
return v
|
||||||
|
|
||||||
def remove(self, v):
|
def remove(self, v):
|
||||||
|
Loading…
Reference in New Issue
Block a user