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

Add Mutex::try_lock and (Unbounded)Receiver::try_recv #1939

Merged
merged 2 commits into from
Dec 10, 2019

Conversation

bikeshedder
Copy link
Contributor

Motivation

  • Mutex::try_lock is missing
  • Receiver::try_recv is missing
  • UnboundedReceiver::try_recv is missing

This makes it (a) impossible to use tokio mutexes and channels in sync code and (b) implement async code that should try to lock/recv and not block.

Solution

  • Add Mutex::try_lock + unit test
  • Add Receiver::try_recv + unit test
  • Add UnboundedReceiver::try_recv + unit test

Most of the doc strings were taken 1:1 from std and and just adopted to match tokio naming conventions. If this is a problem I can rephrase them in my own words. I think it should be no problem though as the std is dual licensed under MIT and Apache License.

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks!

@carllerche carllerche merged commit 9755769 into tokio-rs:master Dec 10, 2019
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

Successfully merging this pull request may close these issues.

None yet

2 participants