by amluto · 3y ago · 0 comments
spawner.spawn(blinky(led)).unwrap();
Has anyone seriously tried structured concurrency for single-threaded async Rust? The pattern where main effectively leaks a task seems kind of gross to me, and it’s exactly what structured concurrency tries to solve.(I realize that Rust’s async is inherently semi-structured.)
They're different tools for different use cases. Structured concurrency is nice when doing related actions concurrently where one might need to cancel the other, while unstructured task spawning makes more sense if they're truly unrelated tasks, that live for the entire duration of the program or where you don't care for how long they live (for example concurrently handling requests in a server).
(disclaimer: Embassy maintainer here)