Condvar::wait_while and Condvar::wait_timeout_while convenience methods
bryanhitc opened this issue · comments
Bryan Hitchcock commented
The standard library has Convar::wait_while
and Convar::wait_timeout_while
methods that take a condition: impl Fn(&mut T) -> bool
. These convenience methods are great since the following pattern is relatively common:
while condition(&mut *lock_guard) {
cv.wait(lock_guard);
}
// condition is now false
I think it'd be great to have these convenience methods built-in, but I can also see an argument being made for not wanting to clutter the public API. Thoughts?
I'm more than happy to submit the PR if this functionality is desired.
Amanieu d'Antras commented
Sure! I'd be happy to accept a PR for this.