aboutsummaryrefslogtreecommitdiff
path: root/rtic-sync
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2025-03-13 22:43:46 +0100
committerEmil Fresk <emil.fresk@gmail.com>2025-03-16 11:19:22 +0000
commit84c7ad186e11b26ed0db5ecc7014dd79d5840bf8 (patch)
treea1ee38f3c64dcb8a47c55ac543e577205d995a95 /rtic-sync
parent4fa3f5ddbac646f0cec0ddb4b95828ce29182ece (diff)
rtic-sync: improve comments
Diffstat (limited to 'rtic-sync')
-rw-r--r--rtic-sync/src/channel.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs
index 00e9476..e33725b 100644
--- a/rtic-sync/src/channel.rs
+++ b/rtic-sync/src/channel.rs
@@ -342,11 +342,12 @@ impl<T, const N: usize> Sender<'_, T, N> {
// We are already in the wait queue.
if let Some(link) = link {
if 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) };
+
// If our link is popped, then:
// 1. We were popped by `try_recv` and it 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.
- let slot = unsafe { free_slot_ptr.replace(None, cs) };
-
if let Some(slot) = slot {
Poll::Ready(Ok(slot))
} else {
@@ -365,10 +366,10 @@ impl<T, const N: usize> Sender<'_, T, N> {
// SAFETY(new_unchecked): The address to the link is stable as it is defined
// outside this stack frame.
- // SAFETY(push): `link_ref` lifetime comes from `link_ptr` that is shadowed,
- // and we make sure in `dropper` that the link is removed from the queue
+ // SAFETY(push): `link_ref` lifetime comes from `link_ptr` and `free_slot_ptr` that
+ // are shadowed and we make sure in `dropper` that the link is removed from the queue
// before dropping `link_ptr` AND `dropper` makes sure that the shadowed
- // `link_ptr` lives until the end of the stack frame.
+ // `ptr`s live until the end of the stack frame.
unsafe { self.0.wait_queue.push(Pin::new_unchecked(link_ref)) };
Poll::Pending