From 09cf0b7af306ba92d2ba930bd871ee9733f8a4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 16 Feb 2020 11:31:37 +0100 Subject: [PATCH] Enter executor context only on `Recipe` creation --- futures/src/runtime.rs | 13 ++++++++++--- winit/src/application.rs | 5 ++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/futures/src/runtime.rs b/futures/src/runtime.rs index ede529dc..d204670b 100644 --- a/futures/src/runtime.rs +++ b/futures/src/runtime.rs @@ -95,11 +95,18 @@ where &mut self, subscription: Subscription, ) { - let futures = - self.subscriptions.update(subscription, self.sender.clone()); + let Runtime { + executor, + subscriptions, + sender, + .. + } = self; + + let futures = executor + .enter(|| subscriptions.update(subscription, sender.clone())); for future in futures { - self.executor.spawn(future); + executor.spawn(future); } } diff --git a/winit/src/application.rs b/winit/src/application.rs index 326dca25..82478107 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -126,7 +126,7 @@ pub trait Application: Sized { let (mut application, init_command) = runtime.enter(|| Self::new()); runtime.spawn(init_command); - let subscription = runtime.enter(|| application.subscription()); + let subscription = application.subscription(); runtime.track(subscription); let mut title = application.title(); @@ -255,8 +255,7 @@ pub trait Application: Sized { debug.update_finished(); } - let subscription = - runtime.enter(|| application.subscription()); + let subscription = application.subscription(); runtime.track(subscription); // Update window title