document WaitableCondvar (#24252)

This commit is contained in:
Jeff Washington (jwash)
2022-04-11 14:45:23 -05:00
committed by GitHub
parent 8a73badf3d
commit c0019edf00

View File

@ -12,12 +12,16 @@ pub struct WaitableCondvar {
}
impl WaitableCondvar {
/// wake up all threads waiting on this event
pub fn notify_all(&self) {
self.event.notify_all();
}
/// wake up one thread waiting on this event
pub fn notify_one(&self) {
self.event.notify_one();
}
/// wait on the event
/// return true if timed out, false if event triggered
pub fn wait_timeout(&self, timeout: Duration) -> bool {
let lock = self.mutex.lock().unwrap();
let res = self.event.wait_timeout(lock, timeout).unwrap();