Hacker News new | ask | show | jobs
by kccqzy 2502 days ago
They have the same semantic complexity. You have tasks in async/await and you still need to deal with inter-task communication, locking, etc.
1 comments

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.
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.