I’m just starting to learn Rust, and was wondering if there is a good way to do coroutines/channels. I’ve grown fond of languages based around CSP, but am not sure that maps well to idiomatic Rust.
Thanks in advance!
I’m just starting to learn Rust, and was wondering if there is a good way to do coroutines/channels. I’ve grown fond of languages based around CSP, but am not sure that maps well to idiomatic Rust.
Thanks in advance!
One approach I’m personally fond of is actor-style async programming with tokio. It’s easy to mingle timers with receiving messages from channels, which is quite powerful. This post by Alice Rhyl is a good description of the idea: https://ryhl.io/blog/actors-with-tokio/
This.
tokio tasks are green threads. https://docs.rs/tokio/latest/tokio/task/
tokio also offers a variety of channels for synchronization between tasks. https://docs.rs/tokio/latest/tokio/sync/index.html