Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix S2 systimers #1979
Fix S2 systimers #1979
Changes from all commits
f4453ff
c38ddcc
ff551b6
804a040
d725936
7615979
29d9b19
e912eb0
01661d0
f78817f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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 move this into the critical section? The register isn't shared on the S2.
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.
The better question is, why wasn't this (and, like all other operations) in a critical section? Every method needs a shared reference only, what prevents users from shooting themselves in the foot by doing things in interrupts that they shouldn't?
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.
Sharing with interrupts requires
Sync
, whichComparator
s aren't (or at least, shouldn't be).The shared reference thing let's you give multiple objects on the same "thread" (interrupt counts as a separate thread) access to the object.
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.
Alarm is Sync as things currently stand :)
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 yeah that needs fixing. Either by adding critical sections in
Alarm
or markingAlarm
s as not Sync.The latter is easier (and maybe also the right way) since
esp-wifi
andesp-hal-embassy
don't take advantage of theSync
, they onlySend
the alarms around.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 would you prefer
!Sync
over&mut self
methods?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 think
&mut self
is artificially restrictive. At the end of the day the volatile registers are basically glorifiedCell
s.I really don't want to have to pull out
RefCell
,Cell
, etc. to share what is already aCell
amongst objects in the same thread.imo, if an exclusive reference isn't needed it shouldn't be required.
If users want to enforce an invariant that requires exclusive access then they can use the Rust tool for that, either by taking ownership of the object or taking a mutable reference to the object. (This is done in
FronzenUnit
for example)Side note there's also this part of the API GUIDELINES.
(Though I suppose pointing it out doesn't matter since we're questioning the guideline itself)