-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Implementation of sync_nonpoison
and nonpoison_mutex
#134663
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
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
This comment has been minimized.
This comment has been minimized.
@Amanieu you may want to double check this |
This comment was marked as resolved.
This comment was marked as resolved.
Looks like you messed up a rebase. No worries, mistakes like this happen sadly (thanks Git for being so hard to use!). To get rid of all these commits, do a |
This comment has been minimized.
This comment has been minimized.
b0a1973
to
f023e42
Compare
This comment has been minimized.
This comment has been minimized.
This seems fine as a first step. Longer term we may want to consider changing the poisoning mutexes to be a wrapper around a non-poisoning |
/// assert_eq!(*mutex.lock(), 10); | ||
/// ``` | ||
#[unstable(feature = "nonpoison_mutex", issue = "134645")] | ||
pub fn try_lock(&self) -> Option<MutexGuard<'_, T>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return TryLockResult<MutexGuard<'_, T>>
according to the API proposed in #134645, where
pub struct WouldBlock;
pub type TryLockResult<Guard> = Result<Guard, WouldBlock>;
|
||
impl<'mutex, T: ?Sized> MutexGuard<'mutex, T> { | ||
unsafe fn new(lock: &'mutex Mutex<T>) -> MutexGuard<'mutex, T> { | ||
return MutexGuard { lock }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return MutexGuard { lock }; | |
MutexGuard { lock } |
@Aandreba you still need to do this to get the test suite to pass, CI should work after that:
|
This comment has been minimized.
This comment has been minimized.
Just tried it, didn't work 😅 🤷 |
What exactly is it doing or not doing? Most of the tests look like just a name update and should be blessable. If for some reason you are having problems running locally, you can also just copy the diff from CI output. E.g. apply the
It would be good to rebase at some point as well, since a few test changes have happened since this branched off. |
@Aandreba do you think you can pick this back up? If not, I would be willing to tackle this, though I am technically on vacation until July 🤪 and won't be able to work on it till then. If you do pick it up, I can at least give my 2 cents: Remembering from when I looked at this in the past, it seemed like the problem was not logic but the boilerplate from the Personally, I would just start again from the master branch and do a lot of copy-pasting (both the boilerplatey/templatey stuff and the new non-poisoning logic) rather than try and rebase everything. Though that's only because I'm not very good at rebasing, you might be better at it than I am. |
I execute the command, it runs succesfully, but the tests keep failing 😅 I honestly have no clue why it's not working, so I'm currently a bit lost. |
Thanks for the help offer! I don't really think rebasing is the issue here, so I don't think redoing it from the start is going to help in this case. |
Mind rebasing at least? If the tests are still not blessing for you, I'll see if I can push a commit that updates them. |
Co-authored-by: oxalica <hooccooh1896@gmail.com>
Co-authored-by: oxalica <hooccooh1896@gmail.com>
Done! Have a try, let me know If you need anything! |
This comment has been minimized.
This comment has been minimized.
So, UI tests have two things that get checked:
Error annotations just highlight the important changes / messages you want to see and need to get updated manually. The stderr files show what the full error output looks like, and get updated with Take a read through https://rustc-dev-guide.rust-lang.org/tests/ui.html, it explains this in better detail. |
The job Click to see the possible cause of the failure (guessed by this bot)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more small comments. Note that there are still some small unresolved comments above that need to be addressed.
Ignore the tidy check failure, looks like NPM might be partially down.
@@ -0,0 +1,10 @@ | |||
//! Non-poisoning syncronous locks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/syncronous/synchronous/
/// A mutual exclusion primitive useful for protecting shared data. | ||
/// | ||
/// For more information about mutexes, check out the documentation for the | ||
/// poisoning variant of this lock found at [std::sync::poison::Mutex](crate::sync::poison::Mutex). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: make this [`poison::Mutex`]
, and then add [`poison::Mutex`]: crate::sync::poison::Mutex
to the bottom of the docs section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test to check the panic behavior?
#[unstable(feature = "nonpoison_mutex", issue = "134645")] | ||
pub fn map<U, F>(orig: Self, f: F) -> MappedMutexGuard<'a, U> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment // #[unstable(feature = "mapped_lock_guards", issue = "117108")]
so we remember this is also unstable under that gate. It would be good to add the same to any API that uses MappedMutexGuard
, and the MappedMutexGuard
itself.
Implementation of
sync_nonpoison
andnonpoison_mutex
Docs come straight from the poisoned Mutex, so they need to be updated.
Tracked by:
sync_nonpoison
andnonpoison_{condvar,mutex,once,rwlock}
#134645