From ee38b04d8b08827c9ec9c970c7c0ab9fc3235c1d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 4 Nov 2020 21:00:47 +0100 Subject: Use static noop `Waker` in `application::run` --- winit/src/application.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'winit/src/application.rs') 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 + '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( +async fn process_events( window: winit::window::Window, proxy: Proxy, mut debug: Debug, -- cgit