3 ms·
Yes, but async Rust is basically built on tokio's runtime, which is what most the big async libraries depend on, like hyper/axum/tokio etc. And tokio is a threa
by m11a 1y ago
Yes, but async Rust is basically built on tokio's runtime, which is what most the big async libraries depend on, like hyper/axum/tokio etc. And tokio is a thread-per-core work-stealing architecture, which requires Send + Sync bounds everywhere. You can avoid them if you depend on tokio-proper, but it's more icky when building on something like axum, where your application handlers also require these bounds.
A good article on this: https://emschwartz.me/async-rust-can-be-a-pleasure-to-work-with-without-send-sync-static/ https://emschwartz.me/async-rust-can-be-a-pleasure-to-work-w...
- tcfhgj 1y agoIirc I had a situation a while back, in which I used async await with tokio with a non Send or Sync type and it compiled when I didn't use spawn[1] (implying multithreading) but a simple loop with sequential processing. Only when I wanted to enable parallelism using spawn, I got a compilation error. [1]: https://docs.rs/tokio/latest/tokio/task/fn.spawn.html https://docs.rs/tokio/latest/tokio/task/fn.spawn.html