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

mpsc::Sender should provide a way to check if a send will succeed #256

Closed
carllerche opened this issue Nov 21, 2016 · 6 comments
Closed

Comments

@carllerche
Copy link
Member

In some cases, it would be very helpful to be able to check if the Sender will be able to accept a new value before "generating" this value. Right now, using Sender always requires an extra "buffer" slot to accept values that are rejected. However, the Sender knows if it can accept another value...

This applies to a number of other Sink implementors as well.

@carllerche carllerche changed the title mpsc::Sender should provide a fn that tests if a send will succeed mpsc::Sender should provide a way to check if a send will succeed Nov 21, 2016
@carllerche
Copy link
Member Author

I propose Sink::poll_ready (in part so that poll_ready shows up when I search the issue tracker!)

@alexcrichton
Copy link
Member

We likely want to add this in the form of a try_send method which just returns the message back if it couldn't be sent (e.g. to make it atomic)

@carllerche
Copy link
Member Author

Try_send doesn't satisfy the original issue which wants a way to know if the channel can accept a value before generating it.

@carllerche
Copy link
Member Author

Being able to check before generating will (probably) be an important feature to correctly implement Service backpressure.

@alexcrichton
Copy link
Member

Ah sorry yes right, forgot about that!

@carllerche
Copy link
Member Author

This is resolved by Sender::poll_ready()

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

2 participants