3 ms·
Can you please elaborate on this? What's an example of a seemingly single threaded simple task where you would turn to async? Does "use async rust everywhere n
by ridiculous_fish 3y ago
Can you please elaborate on this? What's an example of a seemingly single threaded simple task where you would turn to async?
Does "use async rust everywhere now" imply "use tokio everywhere now?" Honest question.
- pornel 3y agoThe way closures made it easy to encapsulate code and state in an object you can run at any time, async encapsulates code and state for ability to run and pause or cancel at any time. This is handy for I/O that can be interleaved and cancelled. You can (ab)use it for other things like generators or various DIY multitasking operations. It can also be a state machine generator (e.g. AI of actors in a game). But I think OP just meant async for typical networking and DB interfaces. And yes, this usually implies the Tokio dependency.