diff options
author | 2020-11-04 21:00:47 +0100 | |
---|---|---|
committer | 2020-11-05 04:09:40 +0100 | |
commit | ee38b04d8b08827c9ec9c970c7c0ab9fc3235c1d (patch) | |
tree | b639c231cf29989cadd41eed63884fa73821111b /winit | |
parent | c153d11aa655119188358a206fb23a718f3d1beb (diff) | |
download | iced-ee38b04d8b08827c9ec9c970c7c0ab9fc3235c1d.tar.gz iced-ee38b04d8b08827c9ec9c970c7c0ab9fc3235c1d.tar.bz2 iced-ee38b04d8b08827c9ec9c970c7c0ab9fc3235c1d.zip |
Use static noop `Waker` in `application::run`
Diffstat (limited to 'winit')
-rw-r--r-- | winit/src/application.rs | 11 | ||||
-rw-r--r-- | winit/src/compositor.rs | 7 |
2 files changed, 14 insertions, 4 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs index fb01bf7a..b34345d7 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -120,6 +120,7 @@ where E: Executor + 'static, C: window::Compositor<Renderer = A::Renderer> + 'static, { + use futures::task::Poll; use futures::{Future, FutureExt}; use winit::event_loop::EventLoop; @@ -150,7 +151,8 @@ where .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| { use winit::event_loop::ControlFlow; @@ -167,8 +169,9 @@ where if let Some(event) = event.to_static() { sender.start_send(event).expect("Send event"); - let mut context = futures::task::Context::from_waker(&waker); - let _ = event_logic.as_mut().poll(&mut context); + if let Poll::Ready(_) = event_logic.as_mut().poll(&mut context) { + panic!("Event logic has stopped running!"); + } } }); } @@ -177,7 +180,7 @@ where /// settings. /// /// [`Application`]: trait.Application.html -pub async fn process_events<A, E, C>( +async fn process_events<A, E, C>( window: winit::window::Window, proxy: Proxy<A::Message>, mut debug: Debug, diff --git a/winit/src/compositor.rs b/winit/src/compositor.rs new file mode 100644 index 00000000..f6ce3075 --- /dev/null +++ b/winit/src/compositor.rs @@ -0,0 +1,7 @@ +use crate::Size; + +pub trait Compositor { + fn window(&self) -> &winit::window::Window; + + fn resize(&self, new_size: Size<u32>); +} |