3 ms·
async/await and goroutine is not same thing here. When you talking about async/await, you're actually talking about asynchronization, and when you talking abou
by rqs 9y ago
async/await and goroutine is not same thing here.
When you talking about async/await, you're actually talking about asynchronization, and when you talking about goroutine, you're talking about parallel (which is a selling point of Go).
If the thread that responsible for executing the async/await blocks, then the entire progress/thread rely on that async/await will block. So if you want to comfortably use async/await, the entire call stack must be build for it, and that can be a huge challenge for the ecosystem of that language.
goroutine resolved that problem by spawn a new system thread so the rest of the progress will not be effected too much by the block. Go also resolved that problem by wrapping IO on top of an internal async API so basic IO operation will not cause actual block for too long.
- pjmlp 9y agoNot necessarily, .NET and C++ task models (as done on Windows) rely on thread pools. When a thread responsible for async/await needs to block, the task is parked and another one will get allocated to the running thread.