Skip to content
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

block_on RFC #11

Open
yoshuawuyts opened this issue May 18, 2020 · 2 comments
Open

block_on RFC #11

yoshuawuyts opened this issue May 18, 2020 · 2 comments

Comments

@yoshuawuyts
Copy link
Member

We saw rust-lang/rust#65875 closed and requiring an RFC. The working group should probably pick this up.

@tmandry tmandry added this to On deck in wg-async work via automation May 26, 2020
@tmandry tmandry removed this from On deck in wg-async work May 26, 2020
@elichai
Copy link

elichai commented Jul 4, 2020

I believe that if we can get a block_on that makes the whole async/await zero cost then this can be really amazing, and then libraries can default to async functions and you can easily convert those to blocking by calling block_on (and maybe in the future it could be part of the language, which will then remove the need for a separate async-std).

Is this even feasible?
Can this:

async fn something(inputs) -> return;

fn main() {
   block_on(something(...));
}

optimize the same as this?

fn something(input) -> return;

fn main() {
something(...);
}

Right now futures_executor::block_on is 100% not zero cost even for the simplest functions.
async: https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=42ad7fb49c98eba138816825153b37ae
regular: https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=42ad7fb49c98eba138816825153b37ae
(look at the ASM difference)

@Thomasdezeeuw
Copy link

I believe that if we can get a block_on that makes the whole async/await zero cost then this can be really amazing, and then libraries can default to async functions and you can easily convert those to blocking by calling block_on (and maybe in the future it could be part of the language, which will then remove the need for a separate async-std).

Doing something "async", e.g. non-blocking I/O, but then blocking is often more costly than doing blocking I/O. So I don't think this is possible for many operations.

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

3 participants