3 ms·
Why? You write the same code with async await but with a keyword at the beginning of every function.
by groundzeros2015 6mo ago
Why? You write the same code with async await but with a keyword at the beginning of every function.
- f_devd 6mo agoBecause if you go down the callstack eventually you won't get the await keyword anymore; you'll get the actual 'waiters' and 'wakers' which define your scheduling
- groundzeros2015 6mo agoYeah. The OS handles scheduling and preemption so it’s done for you rather than a call in the stack.
- pkolaczk 6mo agoOnly if you ever deal with one future at a time. But async allows things like awaiting one of N events in a very natural way. Those patterns are much less readable when done with threads.