Add timeout argument to pump_events

This renames all internal implementations of pump_events_with_timeout
to pump_events and makes them public.

Since all platforms that support pump_events support timeouts there's
no need to have a separate API.
This commit is contained in:
Robert Bragg 2023-07-24 00:37:51 +01:00 committed by Kirill Chibisov
parent e6c7cc297d
commit ae9b02e097
9 changed files with 23 additions and 68 deletions

View file

@ -543,7 +543,7 @@ impl<T: 'static> EventLoop<T> {
}
loop {
match self.pump_events_with_timeout(None, &mut event_handler) {
match self.pump_events(None, &mut event_handler) {
PumpStatus::Exit(0) => {
break Ok(());
}
@ -557,18 +557,7 @@ impl<T: 'static> EventLoop<T> {
}
}
pub fn pump_events<F>(&mut self, event_handler: F) -> PumpStatus
where
F: FnMut(event::Event<'_, T>, &RootELW<T>, &mut ControlFlow),
{
self.pump_events_with_timeout(Some(Duration::ZERO), event_handler)
}
fn pump_events_with_timeout<F>(
&mut self,
timeout: Option<Duration>,
mut callback: F,
) -> PumpStatus
pub fn pump_events<F>(&mut self, timeout: Option<Duration>, mut callback: F) -> PumpStatus
where
F: FnMut(event::Event<'_, T>, &RootELW<T>, &mut ControlFlow),
{