-
Notifications
You must be signed in to change notification settings - Fork 110
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
Adding wait_while
to the loom Condvar.
#167
base: master
Are you sure you want to change the base?
Conversation
…ined with the existing wait, so I lifted the wait_while function body straight from the rust implementation
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.
looks good to me, thanks!
/// Blocks the current thread until this condition variable receives a | ||
/// notification and the given condition returns false. |
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, take it or leave it: we could just copy and paste the entire doc comment from std::sync::Condvar
here, since the API is identical. But, it doesn't really matter (and it looks like other methods on our mock Condvar
don't reproduce the entire std
comment...
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.
I thought about that, but yeah. It didn't seem like that would fit in with the existing comments that were there.
&self, | ||
mut guard: MutexGuard<'a, T>, | ||
mut condition: F, | ||
) -> LockResult<MutexGuard<'a, 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.
I wonder if we could elide these?
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.
No, I tried. Eliding the lifetime completely gives a warning because it’s part of the MutexGuard struct. Trying to make it anonymous gives a complete error because it tries to use the same lifetime as &self.
Also messing with signature seems like a bad idea since we’re trying match what’s in std.
This is just some logic combined with the existing wait, so I lifted the actual wait_while matches exactly what the std::rust implementation does