-
-
Notifications
You must be signed in to change notification settings - Fork 96
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
Re-work defmt-rtt #949
Re-work defmt-rtt #949
Conversation
) Now we use UnsafeCell, and we wrap all the state into a single static variable. ) Moved all the static variables to the top and put the implementation below. Tested with the rust-exercises code for the nRF52-DK.
Deploying knurling-defmt-book with
|
Latest commit: |
63bdd03
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5e3e0fe2.knurling-defmt-book.pages.dev |
Branch Preview URL: | https://rtt-updates.knurling-defmt-book.pages.dev |
The semver-check fail is only for defmt-parser, which should probably just be published. |
TAKEN.store(false, Ordering::Relaxed); | ||
/// Flush the encoder | ||
unsafe fn flush(&self) { | ||
if !self.taken.load(Ordering::Relaxed) { |
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.
I don't think relaxed is correct here? Nothing here enforces an ordering relationship for this load if I see that right. Given that user code can end up calling into here, correct? (similar for the other relaxed ops)
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.
Ah wait nevermind, that's the unsafe part, we expect the lock to be acquired here I suppose
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.
A correct user of this API will call {acquire, write*, flush?, release}
, so this check will never fail in normal operation. The acquire and release calls use critical-section, which contains the appropriate fences.
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.
👍
Tested with the rust-exercises code for the nRF52-DK.