If you do this, you are slowing down your system.
Having a CPU-bound function inside a Tokio task effectively blocks the thread, causing a bottleneck.
A cpu bound function is something cpu intensive like encoding audio or solving a complex algorithm.
To fix this, just use tokio::spawn_blocking
This will transfer the blocking call to a separate thread pool dedicated for blocking operations, thereby maintaining the responsiveness of your app.
Join our community for daily tricks on Rust and software engineering
コメント