4 ms·
Well each time you use the await keyword you are saying its a safe point to exit, which is more predictable than killing at random points. Holding locks across
by fvncc 3y ago
Well each time you use the await keyword you are saying its a safe point to exit, which is more predictable than killing at random points. Holding locks across await points is an anti-pattern, and Rust at least can give a hint if you try to do that. Async/await implementations will also generally allow you to run cleanup code on cancellation (but the exact mechanism depends on the language).
In the end, its about expressing a state machine in a more concise implicit way, which is a suitable level of abstraction for most use cases.