2

There is a feature flag on async-std: tokio1

async-std = { version = "1", features = ["tokio1", "attributes"] }

Then I can use async_std::main on tokio stuff:

#[async_std::main]
async fn main() -> std::io::Result<()> {
    
    // some tokio dependent async libraries run here

    Ok(())
}

Basically it makes tokio dependent crates run with async-std crate.

I have two questions:

  1. How does it work? (what is happening in the background?)
  2. Does it affect the performance to mimic tokio libraries or it is just zero cost abstraction?
Chayim Friedman
  • 47,971
  • 5
  • 48
  • 77
eminfedar
  • 558
  • 3
  • 16
  • 1
    It looks like it just sets the global executor : https://github.com/async-rs/async-global-executor/blob/34f46e07e64f9422292385bfbdad55cbdca9a436/README.md?plain=1#L14 – Ömer Erden Aug 01 '23 at 07:37
  • features called `tokio` are bound to `async-global-executor` dep: https://github.com/async-rs/async-std/blob/7c95bce5356ccb74e46a1a5c9f0d9a6dcb74f8c7/Cargo.toml#L58 – Ömer Erden Aug 01 '23 at 07:39

0 Answers0