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

Adding wait_while to the loom Condvar. #167

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

johnhurt
Copy link

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

…ined with the existing wait, so I lifted the wait_while function body straight from the rust implementation
Copy link
Member

@hawkw hawkw left a 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!

Comment on lines +41 to +42
/// Blocks the current thread until this condition variable receives a
/// notification and the given condition returns false.
Copy link
Member

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...

Copy link
Author

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>>
Copy link
Member

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?

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants