mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-16 21:05:35 +01:00
rtic-sync: take link if it is popped
This commit is contained in:
parent
11699b4391
commit
ea56cc0ce8
1 changed files with 7 additions and 2 deletions
|
|
@ -366,11 +366,16 @@ impl<T, const N: usize> Sender<'_, T, N> {
|
|||
let link = unsafe { link_ptr.get() };
|
||||
|
||||
// We are already in the wait queue.
|
||||
if let Some(link) = link {
|
||||
if link.is_popped() {
|
||||
if let Some(queue_link) = link {
|
||||
if queue_link.is_popped() {
|
||||
// SAFETY: `free_slot_ptr` is valid for writes until the end of this future.
|
||||
let slot = unsafe { free_slot_ptr.replace(None, cs) };
|
||||
|
||||
// Our link was popped, so it is most definitely not in the list.
|
||||
// We can safely & correctly `take` it to prevent ourselves from
|
||||
// redundantly attempting to remove it from the list a 2nd time.
|
||||
link.take();
|
||||
|
||||
// If our link is popped, then:
|
||||
// 1. We were popped by `return_free_lot` and provided us with a slot.
|
||||
// 2. We were popped by `Receiver::drop` and it did not provide us with a slot, and the channel is closed.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue