flume icon indicating copy to clipboard operation
flume copied to clipboard

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

Open thomaseizinger opened this issue 2 years ago • 0 comments

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: https://github.com/zesterer/flume/blob/fcf384956a7badd003c4eca43da5174f4e0c86a0/src/async.rs#L195-L198

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.

thomaseizinger avatar Dec 27 '23 12:12 thomaseizinger