Skip to content
Snippets Groups Projects
Commit e309ed25 authored by Georgy Moshkin's avatar Georgy Moshkin :speech_balloon:
Browse files

refactor(event): events system considered harmful

parent 23520422
No related branches found
No related tags found
1 merge request!433refactor(governor): use a watch channel to wake governor
Pipeline #14529 failed
......@@ -124,47 +124,6 @@ pub fn wait_deadline(event: Event, deadline: Instant) -> Result<WaitTimeout> {
})
}
/// Waits for the event to happen.
///
/// Returns an error if the `EVENTS` is uninitialized.
pub fn wait(event: Event) -> Result<()> {
match wait_timeout(event, Duration::MAX)? {
WaitTimeout::Signal => Ok(()),
WaitTimeout::Timeout => Err(Error::Timeout),
}
}
#[allow(dead_code)]
/// Waits for any of the specified events to happen.
///
/// Returns an error if the `EVENTS` is uninitialized.
pub fn wait_any_timeout(evs: &[Event], timeout: Duration) -> Result<()> {
let mut events = events()?;
let cond = Rc::new(Cond::new());
for &event in evs {
let cond = cond.clone();
events.add_once_handler(
event,
handler(move || {
cond.broadcast();
Ok(())
}),
);
}
// events must be released before yielding
drop(events);
cond.wait_timeout(timeout);
Ok(())
}
#[allow(dead_code)]
/// Waits for any of the specified events to happen.
///
/// Returns an error if the `EVENTS` is uninitialized.
pub fn wait_any(evs: &[Event]) -> Result<()> {
wait_any_timeout(evs, Duration::MAX)
}
/// Signals to everybody who's waiting for this `event` either repeated or one
/// time.
///
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment