3 ms·
How would one go about this in C or Rust? Chans are idiomatic and fast in Golang, what would you do in places lacking that? Context: all my Rust programs recen
by akdor1154 3y ago
How would one go about this in C or Rust? Chans are idiomatic and fast in Golang, what would you do in places lacking that?
Context: all my Rust programs recently have been ending up structured around some threads communicating item-by-item with mpsc_channels. This feels (unsubstantiated) non-ideal, esp if I'm doing something latency sensitive like processing input. But what, if anything, to do instead?
- kccqzy 3y agoC is a language without much of a standard library. To do this in C you'd first need to write a coroutine library. In Rust, your approach sounds fine. However you should also consider simply using Rust's iterator. Define a struct containing the state you want, then implement it as an Iterator. In the future, you can also just write control flow and have the compiler transform that for you. Take a look at the first few sections of https://lang-team.rust-lang.org/design_notes/general_coroutines.html https://lang-team.rust-lang.org/design_notes/general_corouti...