Skip to content

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.

@emakryo
Copy link

emakryo commented Nov 13, 2024

Are there any blocking issues for this PR? I appreciate that we can use this API in loom. Thank you!

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.

4 participants