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

{MutexGuard, RwLockReadGuard, RwLockWriteGuard}::map #44189

Closed
QuietMisdreavus opened this issue Aug 30, 2017 · 5 comments
Closed

{MutexGuard, RwLockReadGuard, RwLockWriteGuard}::map #44189

QuietMisdreavus opened this issue Aug 30, 2017 · 5 comments
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@QuietMisdreavus
Copy link
Member

Currently, the RefCell borrow guards have a function called map which allows you to transform a borrow of a whole struct to a borrow of one of its fields (or of some related reference with the same lifetime). Would it be possible to add these methods to Mutex and RwLock?

@QuietMisdreavus QuietMisdreavus added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Aug 30, 2017
@sfackler
Copy link
Member

It's come up before, but is unsound: #30834 (comment).

@QuietMisdreavus
Copy link
Member Author

Ah, curses. Thanks for the link; i'll go ahead and close this out then.

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Jun 25, 2018

The linked comment only says that MutexGuard::map would be unsound, not the RwLock*::map methods (which I could use right now) - can you reopen, @QuietMisdreavus?

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Jun 25, 2018

Ah I see this was already discussed in #27746 (comment), so nevermind

EDIT: That said, map could simply return a MappedMutexGuard or MappedRwLock*Guard to fix the soundness problems.

@xmo-odoo
Copy link

Ah I see this was already discussed in #27746 (comment), so nevermind

EDIT: That said, map could simply return a MappedMutexGuard or MappedRwLock*Guard to fix the soundness problems.

For any reader stumbling upon this issue, that seems to be the option parking_lot uses: its rw guards are mappable and return a dedicated MappedGuard structure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants