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: Add Sender::try_reserve function #3418

Merged
merged 3 commits into from
Jan 13, 2021
Merged

Conversation

LucioFranco
Copy link
Member

Add a try_reserve function to the mpsc Sender. This allows to attempt to query the Sender for available send slots without having to materialize the T value.

tokio/src/sync/mpsc/bounded.rs Outdated Show resolved Hide resolved
@LucioFranco LucioFranco added A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-sync Module: tokio/sync labels Jan 13, 2021
@LucioFranco LucioFranco merged commit 672be92 into master Jan 13, 2021
@LucioFranco LucioFranco deleted the lucio/try-reserve branch January 13, 2021 19:24
@Darksonn Darksonn mentioned this pull request Jan 22, 2021
//// If the channel is full this function will return [`TrySendError`], otherwise
/// if there is a slot available it will return a [`Permit`] that will then allow you
/// to [`send`] on the channel with a guaranteed slot. This function is similar to
/// [`reserve`] execpt it does not await for the slot to become available.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: :s/execpt/except/g

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRS WELCOME RORY!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone's going to address this typo, consider also mentioning the new try_reserve in Permit's rustdoc (currently it only mentions reserve as returning it). I can submit that PR if nobody else is on it 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-enhancement Category: A PR with an enhancement or bugfix. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants