Skip to content

Can not use a custom executor #663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
realcr opened this issue Jan 8, 2020 · 1 comment
Open

Can not use a custom executor #663

realcr opened this issue Jan 8, 2020 · 1 comment

Comments

@realcr
Copy link

realcr commented Jan 8, 2020

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:

Possibly related to issue: #79

@yoshuawuyts
Copy link
Contributor

@realcr it sounds like what you want is perhaps a global hook for executors. Making async-std deterministic has not been part of the design so far; we've focused on making it accessible, performant, and complete.

However I'm sympathetic to your use case, and see how that could be valuable. Thanks for raising this, we'll keep this issue open!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants