Unified lock types for rustpython_common#2239
Merged
Merged
Conversation
9a7e027 to
7a39500
Compare
youknowone
reviewed
Oct 2, 2020
| mod cell_lock; | ||
| pub use cell_lock::{RawCellMutex as RawMutex, RawCellRwLock as RawRwLock}; | ||
|
|
||
| pub use once_cell::unsync::{Lazy, OnceCell}; |
Member
Author
There was a problem hiding this comment.
I think it makes sense there; sync::OnceCell at least has to lock when it's initializing
Member
Author
There was a problem hiding this comment.
And it was there when this was cell.rs as well
youknowone
approved these changes
Oct 2, 2020
youknowone
left a comment
Member
There was a problem hiding this comment.
I am not understanding this very well. Any other reviewer for this?
If possible, merging #2226 first maybe helpful. @qingshi163 experienced a lot of rebasing for that already
Member
Author
|
I suppose so, I'd just like to have them merged close together so that we don't run into issues with the soundness hole. |
Member
Author
|
I'm gonna merge this; I feel like |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #2226 and specifically in order to implement
BorrowedValue::map(); I realized that we can just make our ownRawMutex/RawRwLockand use it to define the Mutex types. These should be faster, too,since RefCell has more overhead (immutable accessor count mainly,since they're more direct with the use case -- e.g. just one writer vs RefCell supports multiple withCell<isize>vsCell<bool>)RefMut::map_split. Turns out we can't actually make it a bool, since we subtly depend on PyRwLock having a recursive locking behavior, even though that's not guaranteed by parking_lot -- "Note that attempts to recursively acquire a read lock on aRwLockwhen the current thread already holds one may result in a deadlock."