Skip to content

Commit

Permalink
Set is_unparking in dequeue{_all}
Browse files Browse the repository at this point in the history
  • Loading branch information
mpage committed Feb 3, 2024
1 parent cd85723 commit 33fea69
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Python/parking_lot.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ dequeue(Bucket *bucket, const void *address)
if (wait->addr == (uintptr_t)address) {
llist_remove(node);
--bucket->num_waiters;
wait->is_unparking = true;
return wait;
}
}
Expand All @@ -262,6 +263,7 @@ dequeue_all(Bucket *bucket, const void *address, struct llist_node *dst)
llist_remove(node);
llist_insert_tail(dst, node);
--bucket->num_waiters;
wait->is_unparking = true;
}
}
}
Expand Down Expand Up @@ -337,8 +339,6 @@ _PyParkingLot_Unpark(const void *addr, _Py_unpark_fn_t *fn, void *arg)
_PyRawMutex_Lock(&bucket->mutex);
struct wait_entry *waiter = dequeue(bucket, addr);
if (waiter) {
waiter->is_unparking = true;

int has_more_waiters = (bucket->num_waiters > 0);
fn(arg, waiter->park_arg, has_more_waiters);
}
Expand All @@ -362,10 +362,6 @@ _PyParkingLot_UnparkAll(const void *addr)

_PyRawMutex_Lock(&bucket->mutex);
dequeue_all(bucket, addr, &head);
llist_for_each(node, &head) {
struct wait_entry *waiter = llist_data(node, struct wait_entry, node);
waiter->is_unparking = true;
}
_PyRawMutex_Unlock(&bucket->mutex);

llist_for_each_safe(node, &head) {
Expand Down

0 comments on commit 33fea69

Please sign in to comment.