-
Notifications
You must be signed in to change notification settings - Fork 214
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
actor API #537
base: master
Are you sure you want to change the base?
Conversation
@rtic-rs/devs this PR has been rebased onto rtic 1.0 and the deps of the firmware have also been bumped 🚀 |
ping @korken89 this and the rtic-syntax PRs have been rebased |
Now with |
Looking at the |
indeed, having the temp sensor as an actor instance makes more sense. updated the example. |
see rtic-rs/rfcs#52 for details includes: core proposal and `#[init]` and `memory-watermark` extensions Co-authored-by: Jonas Schievink <[email protected]>
this way it won't be compiled by `cargo b --examples` it'll be compiled by 'cargo b --examples --features actor-watermark`
@korken89 review ping. (someone else also asked about when this would be merged in the matrix chat room) |
{ | ||
fn receive(&mut self, temperature: TemperatureReadingCelsius) { | ||
if temperature.0 >= self.threshold { | ||
self.outbox.post(TemperatureAlert).ok().expect("OOM"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is ok()
called here when you could call expect directly on the return from post()
i.e.
self.outbox.post(TemperatureAlert).expect("OOM");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing expect
on the Result<T, E>
value requires that E
implements the fmt::Debug
trait. doing ok().expect()
places no trait requirements on the type E
. TemperatureAlert
does not implement the fmt::Debug
trait so post(TemperatureAlert).expect()
would not compile.
deriving Debug
on the type and leaving out the ok()
is also an option (no pun intended). I tend to write ok().expect()
mostly out of bad habit. (less Result::unwrap
calls produces smaller (code size) binaries but that's micro-optimizing and this is an example so that hardly matters; as I said: bad habit)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, ok makes sense. Thanks for the reply, I was mainly just curious more than critiquing
What's the status of this, now that v2.0 is stable? |
The proposed path forward is to create a separate branch for actor, just like other older releases. |
this PR contains a proof-of-concept implementation of the actor API proposed in rtic-rs/rfcs#52
the files added to the
examples
directory are tests of the feature semanticsa full example, with multiple crates (firmware + testable
no_std
library), has been included in theactor-example
directorydepends on rtic-rs/rtic-syntax#75