Conversation
poll_recv was previously unimplemented. The new implementation stores a persistent Acquire future in ReceiverInternal so the semaphore waiter stays registered across polls. When the channel is empty, the caller is properly suspended via the semaphore waiter queue until a message arrives or the channel closes. recv, try_recv, and blocking_recv are reimplemented atop poll_recv so that semaphore interaction is centralized in a single code path. try_recv polls once with a noop waker and clears the pending acquire on Pending; recv uses poll_fn; blocking_recv uses block_on(recv). The Acquire future borrows recv_semaphore behind Arc<Channel>, with the lifetime transmuted to 'static. This is sound because pending_acquire is always cleared before chan is dropped. Add parity tests for bounded and unbounded poll_recv, plus a test that interleaves poll_recv with recv to verify no permit leak. 🤖 Assisted by AI Cherry-picked from ShuttleTokio commit fb6e01b7, with poll_recv_then_recv_no_leak changed to use a capacity-1 channel so that a leaked permit is actually observable (it would deadlock the send) rather than being masked by the spare capacity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
poll_recv was previously unimplemented. The new implementation
stores a persistent Acquire future in ReceiverInternal so the
semaphore waiter stays registered across polls. When the channel
is empty, the caller is properly suspended via the semaphore
waiter queue until a message arrives or the channel closes.
recv, try_recv, and blocking_recv are reimplemented atop poll_recv
so that semaphore interaction is centralized in a single code path.
try_recv polls once with a noop waker and clears the pending acquire
on Pending; recv uses poll_fn; blocking_recv uses block_on(recv).
The Acquire future borrows recv_semaphore behind Arc,
with the lifetime transmuted to 'static. This is sound because
pending_acquire is always cleared before chan is dropped.
Add parity tests for bounded and unbounded poll_recv, plus a test
that interleaves poll_recv with recv to verify no permit leak.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.