document WaitableCondvar (#24252)
This commit is contained in:
parent
8a73badf3d
commit
c0019edf00
|
@ -12,12 +12,16 @@ pub struct WaitableCondvar {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WaitableCondvar {
|
impl WaitableCondvar {
|
||||||
|
/// wake up all threads waiting on this event
|
||||||
pub fn notify_all(&self) {
|
pub fn notify_all(&self) {
|
||||||
self.event.notify_all();
|
self.event.notify_all();
|
||||||
}
|
}
|
||||||
|
/// wake up one thread waiting on this event
|
||||||
pub fn notify_one(&self) {
|
pub fn notify_one(&self) {
|
||||||
self.event.notify_one();
|
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 {
|
pub fn wait_timeout(&self, timeout: Duration) -> bool {
|
||||||
let lock = self.mutex.lock().unwrap();
|
let lock = self.mutex.lock().unwrap();
|
||||||
let res = self.event.wait_timeout(lock, timeout).unwrap();
|
let res = self.event.wait_timeout(lock, timeout).unwrap();
|
||||||
|
|
Loading…
Reference in New Issue