3 ms·
I thought async/await creates a state machine in the background. If so, there should be a runtime cost. State machines to deal with interrupts (to name the mos
by scoutt 3y ago
I thought async/await creates a state machine in the background. If so, there should be a runtime cost.
State machines to deal with interrupts (to name the most basic kind of async event) is the ABC of embedded "bare metal" programming.
Whether async/await is cleaner, easier, readable, etc. is a matter of taste.
- ComputerGuru 3y agoNo, it compiles to a state machine (there is no “background”) and you just loop over the fixed list of futures/tasks in your main calling next/poll() to step through the states - there is no runtime so you have to do that yourself.
- scoutt 3y agoYes, "compiles to state machine" is what I meant. > you have to do that yourself Yes. And it has a cost. Plus the cost of executing that state machine (changing states, etc.), which is hidden from you. One can always pull a more optimized and fine-tuned state machine made by hand (sitting on WFI for example), and here comes the "taste" factor.