Re:How Rust optimizes async/await
by lalaland1125 on Monday August 19, 2019 @09:53PM
(#20743238)
The main difference is that in async/await you control where context switches occur and the syntax (.await) explicitly points them out. This means you can often avoid locks and do things in a more straightforward manner.
[ Parent
| on HN ]
Re:How Rust optimizes async/await
by GolDDranks on Monday August 19, 2019 @11:57PM
(#20743717)
Note that this applies only to tasks that are !Sync. If they aren't, two tasks accessing the same state could be moved to different threads and access that state racily. In that case .await tells you nothing about accessing non-local state. However, for purposefully single-threaded task pools avoiding locks this way certainly seems possible.