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 map method to MutexGuard, RwLockReadGuard, RwLockWriteGuard #2471

Closed
sunjay opened this issue Apr 30, 2020 · 2 comments · Fixed by #2472
Closed

Add map method to MutexGuard, RwLockReadGuard, RwLockWriteGuard #2471

sunjay opened this issue Apr 30, 2020 · 2 comments · Fixed by #2472
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-sync Module: tokio/sync

Comments

@sunjay
Copy link
Contributor

sunjay commented Apr 30, 2020

Thanks for such an excellent crate! I'm really enjoying using it and it's very well documented. 😄

Version

tokio v0.2.20

Description

The parking_lot crate provides a map method on MutexGuard, RwLockReadGuard, RwLockWriteGuard that is very convenient when you need to return some part of a locked value. For example, this can be used to implement a method that return a reference to a single field of a value that you previously locked.

Would it be possible for tokio to add these methods to its lock guards? Are there any major complications that could be encountered due to async or because of the mutex implementation?

I'd be willing to work on this if no one else is available. (Though I would not object if someone else is willing to take this on.)

@hawkw
Copy link
Member

hawkw commented Apr 30, 2020

You may be happy to learn that there's already a PR open to add map methods to the RwLock guards!

@sunjay
Copy link
Contributor Author

sunjay commented Apr 30, 2020

@hawkw This is great! I'm going to get started on a PR for adding map to MutexGuard. 🎉

@Darksonn Darksonn added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-sync Module: tokio/sync labels May 1, 2020
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-feature-request Category: A feature request. M-sync Module: tokio/sync
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants