3 ms·
Another viable strategy is to start a single-threaded tokio executor and treat it like another thread that you communicate with over (flume) channels.
by wongarsu 3y ago
Another viable strategy is to start a single-threaded tokio executor and treat it like another thread that you communicate with over (flume) channels.
- littlestymaar 3y agoYes this works too. People complaining about async being contaminant are often so much prejudiced against it that that haven't even tried to understand the basics.
- dymk 3y agoI have plenty of gripes about async in rust, but one of the things it's surprisingly good at is isolation of async runtimes. There's no reason you can't have multiple tokio runtimes, or transient runtimes, in your application. Now if only the other warts were fixed, like the particularly poor compiler errors when there's an issue within an async function...
- tuetuopay 3y agoYup. I was blown away when I spun up five different tokio runtimes in the same app all communicating through channels. I expected at least the tokio-aware channels to be problematic but not in the slightest. It's now humming in prod doing its business. Once you get the basics, it's quite easy to lego stuff out and get the best of both worlds.
- LtWorf 3y agoHaving written an async library (as in, the non-blocking stuff and state, that to the caller looks like async)... Understanding it isn't the easiest.
- mplanchard 3y agoYeah writing the underlying machinery is definitely much more complicated! Most users of async libraries don't need to worry about this though