Tokio: span/block_on without creating a new Runtime

  1. I want to use Runtime in tokio::runtime - Rust

  2. I don't want to create a new Runtime.

  3. Is there a way to tell tokio: "spawn on current runtime" ?

  4. If not, do I have to pass an Arc<Runtime> around ?

This whole thing is kind of weird, it is a followup to Drop handler, tokio::sync::Mutex, async where if I want to call async in the drop handler, I need to somehow have access to a tokio RunTime -- this then implies I need to keep a Arc<tokio::Runtime> in every struct whose drop handler might do some async work ?

Doesn't tokio::spawn do exactly this?

1 Like

I've been playing with Runtime in tokio::runtime - Rust recently and forgot that there was a separate tokio::spawn

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.