async closures version? - #28
Conversation
|
Please add tokio as a dev-dependency, otherwise you break |
|
Also, is there a way to support both sync and async simultaneously? Like, a |
|
If not, I strongly vote for this, @funbiscuit. As async seems to be the future of embedded. For example, It's cumbersome but possible to interact with USB using the current state of this crate, through queues, but it's almost impossible to execute async tasks from handler functions. Which is a very common usecase for an embedded CLI nowadays. And that's exactly what this change would fix. |
you can have copies of every function I had to make async |
I'm not really interested in this crate because I don't need it at the moment, so feel free to work on this yourself, I literally changed like 20 lines of code following my editor to make thism |
That's a tough question, both options (drop sync support or make function duplicates) don't seem good for me. I think you can fork and manually make functions async as shown in this branch. Until a proper solution is found. |
|
actually it's not hard to have both blocking and async version, because blocking code can work with async code, but not viceversa. usually blocking code is seen as more versatile and with more compatibility, but it's actually the opposite. something else entirely is blocking code that does not block but has callbacks, like in C without an RTOS, but that's the same pattern as async. to have a blocking version the caller can just poll once the process function, and if his code is blocking it should be always Poll::ready on the first try. I added a @Finomnis now both blocking and async code are supported. |
|
With priority inversions, I mean even threads of the same priority (in RTIC) will not run if you do not |
|
then we can put an error like |
|
Sounds better, yes :) |
|
@Finomnis what do you think? |
|
I would not return Also again, Tokio should be a dev dependency :) |
|
why is |
Because its only intended use is as the return value of the |
|
@Finomnis is it fine now? |
|
Sounds good :) question is if it will ever get merged though... |
|
As I said before, it does look good if we accept there is only one way to do things - use async/await. I'm not convinced with it and thats backwards incompatible change. So can't merge it as is for now. |
I expected that already, it's fine :) |
|
I made it backwards compatible; now there is a sync |
| } | ||
|
|
||
| fn main() { | ||
| #[tokio::main] |
There was a problem hiding this comment.
If truly backwards compatible, this file should not change
There was a problem hiding this comment.
I forgot to edit the example, sorry, in fact I believe it doesn't build anymore.
|
Now it should be fully working and backwards compatible. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #28 +/- ##
==========================================
- Coverage 85.44% 85.27% -0.18%
==========================================
Files 15 15
Lines 1381 1419 +38
==========================================
+ Hits 1180 1210 +30
- Misses 201 209 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@tommasoclini This looks promising, thanks. I'll take a more in depth look later. Also I suggest adding at least some basic e2e test (or new example) that uses async version. Copy of existing example would be the best. |
|
@funbiscuit I tried building the arduino example first with the commit right before I started and the latest one of this PR, there's a pretty big size increase: old: new: Maybe we should wait before merging. |
|
I think we should use maybe_async_cfg2 here. |
|
I'm closing this PR because I have opened #30 which takes a completely different approach. |
No description provided.