Can not use a custom executor
- Dominant language
- Rust
- Stars
- 4.1k
- Forks
- 339
- PR merge metrics
- No merged PRs in 30d
Description
Hi, thank you for your work on async-std!
I noticed that the function `spawn_blocking` and every function that relies on it (for example, all the file related operations) does not allow choosing an executor. From the documentation:
> The task will be spawned onto a thread pool specifically dedicated to blocking tasks. This is useful to prevent long-running synchronous operations from blocking the main futures executor.
I was very surprised to read this line in the documentation. My usual experience with rust libraries is that everything is zero cost abstraction, or at least attempts to be as much as possible. Creating an implicit executor seems to be going in the other direction.
For all my testing I am using a deterministic executor that allows to detect deadlocks and simulate the passage of time.
An example, If I choose to use a function like `async_std::fs::remove_dir` anywhere in my code, I will not be able to use my deterministic executor to test the code. Because now, instead of having one test executor that I control, I also get an additional implicit executor from inside `async-std` that is out of my control.
Is there any workaround if I want to be able to use my executor instead of the implicit one provided by `async-std`?
EDIT: This issue seems to be a problem that repeats in other async frameworks. See also:
- https://github.com/http-rs/tide/issues/276
- https://github.com/actix/actix-web/issues/913
Possibly related to issue: https://github.com/async-rs/async-std/issues/79
Contributor guide
Assessment
This issue has not been assessed yet.