Support ready() for mpsc::Receiver #6965
Labels
A-tokio
Area: The main tokio crate
C-feature-request
Category: A feature request.
M-sync
Module: tokio/sync
Is your feature request related to a problem? Please describe.
I have an application that needs to wait for a value to show up in a channel within a certain time-frame before running some business logic.
Describe the solution you'd like
The ideal solution would be to have a
async peek()
functionality which is ready when a value has been sent but does not consume the value.Describe alternatives you've considered
Alternative 1. Is to await on
recv()
and write our business logic to work with the first channel value as a special case.Alternative 2. Is to wrap the Receiver in a ReceiverStream, convert it into a Peekable stream and call peek on that.
My main gripe is that after the conversion to Peekable, we cannot get the original receiver back as we have a lot of logic that depends on Receiver type and we will have to change this to be Peekable or worse, a generic Stream.
The text was updated successfully, but these errors were encountered: