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 <dev@notgull.net>
This commit is contained in:
John Nunley 2023-11-01 19:41:01 -07:00 committed by John Nunley
parent 19ca79660f
commit 75c8dcedfa
1 changed files with 5 additions and 1 deletions

View File

@ -49,7 +49,11 @@ pub fn spawn<T: Send + 'static>(future: impl Future<Output = T> + 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
})
}