-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async? #6
Comments
If we are all using this within embassy, maybe support only the async version of this lib? Async write, erase and read traits could still be implemented by blocking functions if that's the only way how MCU supports flash operations. nrf52x already writes to internal flash asynchronously via softdevice. |
Yeah that's what I was thinking. The only feasible thing to do is ask to complete the future and give no guarantees for dropped futures. |
@diondokter Have you had anymore thoughts on how to approach this? I made a stab locally replacing embedded-storage with embedded-storage-async, and first hurdle was the callback/closure-based iteration of the headers. In order to simplify the conversion to async in the future, I'd like to change that to have an iterator-like API that can more easily be converted to async for instance. As for the non-async version, there is https://github.com/embassy-rs/embassy/blob/main/embassy-embedded-hal/src/adapter/blocking_async.rs which can be used to wrap a non-async flash in an async interface. Depending on how you want to do it, one could either expose the blocking APIs and use that type internally or just point users to it. The part about cancellation I'm not sure, in general cancellation is a nightmare and having a big sign saying 'thou shalt not cancel this future' is OK imho. |
@lulf Yeah, converting it to an iterator style could be possible. My first thought would be to make the closure return a future (so it simulates an async closure) so the API can remain the same. But if you can find a better API for it, then I'm interested. The current one works, but isn't amazing. I didn't know embassy had adapters like that! (Though it's missing the async multiwrite norflash, but that is easily added.) With regard to cancellation, that is what #16 is also for. James Munns argued that cancellation isn't all that different to a random power shutdown. So that's why I worked on that. Hopefully any cancellation will only lead to possible repairable corruption. So we'd just have to document that and say 'cancel on your own risc'. |
Closed by #17 |
Writing and reading from an external flash chip can take quite a while. So this library should ideally be async.
But how to do that?
I don't want to maintain both a blocking and an async version of the same thing...
The text was updated successfully, but these errors were encountered: