Use static noop Waker in application::run
This commit is contained in:
parent
c153d11aa6
commit
ee38b04d8b
2 changed files with 14 additions and 4 deletions
|
|
@ -120,6 +120,7 @@ where
|
||||||
E: Executor + 'static,
|
E: Executor + 'static,
|
||||||
C: window::Compositor<Renderer = A::Renderer> + 'static,
|
C: window::Compositor<Renderer = A::Renderer> + 'static,
|
||||||
{
|
{
|
||||||
|
use futures::task::Poll;
|
||||||
use futures::{Future, FutureExt};
|
use futures::{Future, FutureExt};
|
||||||
use winit::event_loop::EventLoop;
|
use winit::event_loop::EventLoop;
|
||||||
|
|
||||||
|
|
@ -150,7 +151,8 @@ where
|
||||||
.map(|_| ()),
|
.map(|_| ()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let waker = futures::task::noop_waker();
|
let mut context =
|
||||||
|
futures::task::Context::from_waker(futures::task::noop_waker_ref());
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
use winit::event_loop::ControlFlow;
|
use winit::event_loop::ControlFlow;
|
||||||
|
|
@ -167,8 +169,9 @@ where
|
||||||
if let Some(event) = event.to_static() {
|
if let Some(event) = event.to_static() {
|
||||||
sender.start_send(event).expect("Send event");
|
sender.start_send(event).expect("Send event");
|
||||||
|
|
||||||
let mut context = futures::task::Context::from_waker(&waker);
|
if let Poll::Ready(_) = event_logic.as_mut().poll(&mut context) {
|
||||||
let _ = event_logic.as_mut().poll(&mut context);
|
panic!("Event logic has stopped running!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -177,7 +180,7 @@ where
|
||||||
/// settings.
|
/// settings.
|
||||||
///
|
///
|
||||||
/// [`Application`]: trait.Application.html
|
/// [`Application`]: trait.Application.html
|
||||||
pub async fn process_events<A, E, C>(
|
async fn process_events<A, E, C>(
|
||||||
window: winit::window::Window,
|
window: winit::window::Window,
|
||||||
proxy: Proxy<A::Message>,
|
proxy: Proxy<A::Message>,
|
||||||
mut debug: Debug,
|
mut debug: Debug,
|
||||||
|
|
|
||||||
7
winit/src/compositor.rs
Normal file
7
winit/src/compositor.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
use crate::Size;
|
||||||
|
|
||||||
|
pub trait Compositor {
|
||||||
|
fn window(&self) -> &winit::window::Window;
|
||||||
|
|
||||||
|
fn resize(&self, new_size: Size<u32>);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue