Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendFut::poll should return Poll::Pending for rendezvous channels when no item is queued #140

Open
thomaseizinger opened this issue Dec 27, 2023 · 0 comments

Comments

@thomaseizinger
Copy link

thomaseizinger commented Dec 27, 2023

I have a rendezvous channel with one Receiver and multiple senders, each sender sitting in its own task. I'd like these tasks to wake up when the Receiver gets dropped. For this to work, the task needs to suspend on SendSink::poll_ready.

Today, this does not work because SendFut returns Poll::Ready if it does not have anything to do:

flume/src/async.rs

Lines 195 to 198 in fcf3849

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
if let Some(SendState::QueuedItem(hook)) = self.hook.as_ref() {
if hook.is_empty() {
Poll::Ready(Ok(()))

I don't think this is correct. Instead of always returning Poll::Ready, I think the future needs to check, whether there would be capacity to send an item and if there isn't like in the case of a rendezvous channel, register a waker and return Poll::Pending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant