Cassette
A simple, single-future, non-blocking executor intended for building state machines. Designed to be no-std and embedded friendly.
This executor TOTALLY IGNORES wakers and context, meaning that all async functions should expect to be polled repeatedly until completion.
Inspiration
So, I'm really not good at async, but I like the idea of being able to use the ability to yield or await on tasks that will require some time to complete.
The idea here is that you would write one, top level async
function that would either eventually resolve to some value, or that will run forever (to act as a state machine).
How it works
- You write some async functions
- You call the "top level" async function
- You poll on it until it resolves (or forever)
Note: This demo is available in the demo/
folder of this repo.
Step 1 - You write some async functions
Here's the "context" of our state machine, describing a couple of high level behaviors, as well as individual substeps.
We can also make simple little futures for code that needs to be polled until ready:
static FAKE: AtomicU32 = new;
;
async
Step 2 - You call the "top level" async function
Step 3 - You poll on it until it resolves (or forever)
A larger demo
If you'd like to see a larger demo, I used Cassette to implement an I2C peripheral bootloader state machine for a thumbv6m
target. You can check out that PR for more context.
License
This crate is licensed under the MIT and Apache 2.0 licenses.