|
|
|
|
|
by nominatronic
822 days ago
|
|
> Fibers and async/await are backed by the same OS APIs async/await doesn't require any OS APIs, or even an OS at all. You can write async rust that runs on a microcontroller and poll a future directly from an interrupt handler. And there's a huge advantage to doing so, too: you can write out sequences of operations in a straightforward procedural form, and let the compiler do the work of turning that into a state machine with a minimal state representation, rather than doing that manually. |
|
Fibers are built on yielding execution to someone else, which is implemented trivially on embedded targets. Arguably, in a certain sense, fibers can be even better suited for embedded since they allow preemption of task by interrupts at any moment with interrupts being processed by another task, while with async/await you have to put event into queue and continue execution of previously executed future.