3 ms·
Yeah the author makes a really poor example with the async case here. Async in rust is done via cooperative scheduling. If you call await you enter a potential
by stevenhuang 7mo ago
Yeah the author makes a really poor example with the async case here.
Async in rust is done via cooperative scheduling. If you call await you enter a potential suspension point. You're willingly telling the scheduler you're done running and giving another task a chance to run. Compound that with something like tokio's work stealing and now you'll possibly have your task migrated to run on a different thread.
If this is in hot path making another call to await is probably the worst thing you can do lol.
The author demonstrates later with a dead simple inlining example that the asm is equivalent. Wonder why he didn't try that with await ;)