From 75c8dcedfab2e9be2630e83d68f0440a8d05bccd Mon Sep 17 00:00:00 2001 From: John Nunley Date: Wed, 1 Nov 2023 19:41:01 -0700 Subject: [PATCH] Run the process driver on the executor thread This allows us to avoid spawning an additional thread in some cases. Signed-off-by: John Nunley --- src/spawn.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/spawn.rs b/src/spawn.rs index 4741948..b31494d 100644 --- a/src/spawn.rs +++ b/src/spawn.rs @@ -49,7 +49,11 @@ pub fn spawn(future: impl Future + Send + 'static .expect("cannot spawn executor thread"); } - Executor::new() + // Prevent spawning another thread by running the process driver on this thread. + let ex = Executor::new(); + #[cfg(not(target_os = "espidf"))] + ex.spawn(async_process::driver()).detach(); + ex }) }