soenkehahn / cradle

Rust library for running child processes
Creative Commons Zero v1.0 Universal
38 stars 5 forks source link

Switch to async io to avoid spawning three OS threads per command #197

Open soenkehahn opened 3 years ago

soenkehahn commented 3 years ago

Without this PR cradle spawns 3 OS threads (with std::thread::spawn) per executed child process. These are used to write to stdin and read from stderr and stdout. This PR switches to using tokio and async io. This may be good, since -- at least on linux -- OS threads are not super efficient.

This is currently just a WIP PR.

One open question: Can we even start a tokio runtime without destroying the ability of library users to use async runtimes themselves?