18 karma · joined Mar 6, 2015 (11y ago) · 5 submissions
comment 10mo ago · link · parent
You can get preemptive scheduling of async tasks with InterruptExecutor. You create one executor for each priority level, then spawn the tasks in the right one. The latency of the executor and the compiler-generated async state machines is predictable, so you can use Embassy for hard real-time work. See example: https://github.com/embassy-rs/embassy/blob/main/examples/nrf...
Additionally the executor has support for scheduling tasks by priority or deadline within a single priority level. (in latest git, will be in next crates.io release)
comment 3y ago · link · parent
There's other companies using Embassy in production. Sadly firmwares are usually not open source. There's a few non-toy open-source projects using Embassy though:
- https://github.com/nviennot/turbo-resin
- https://github.com/ivmarkov/ruwm
- https://github.com/dkhayes117/propane-monitor-embassy
(disclaimer: Embassy maintainer, Akiles CTO here)
comment 3y ago · link · parent
This is what makes it work nicely on embedded. The compiler-generated state machines are structs with fixed size so they can be statically allocated. Callbacks would have to be heap-allocated and garbage-collected/refcounted.
(disclaimer: Embassy maintainer here)
comment 3y ago · link · parent
They're different tools for different use cases. Structured concurrency is nice when doing related actions concurrently where one might need to cancel the other, while unstructured task spawning makes more sense if they're truly unrelated tasks, that live for the entire duration of the program or where you don't care for how long they live (for example concurrently handling requests in a server).
(disclaimer: Embassy maintainer here)
comment 3y ago · link · parent
The `embedded-hal-async` traits can be implemented with DMA, the Embassy HALs do so. This is a problem with the `nb` traits only.
> The APIs tend to be a mess due to heavy use of typestates
This is an issue of some HAL crates implementing the traits, not with the `embedded-hal` traits themselves. I also dislike the heavy use of typestates/generics, Embassy tries to implement the traits while keeping typestates at a minimum.
(disclaimer: Embassy maintainer here)