-
Notifications
You must be signed in to change notification settings - Fork 12
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
refactor(threads): improve panic handling and docs #382
Conversation
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.
That leaves the documentation of this module in a much better state.
I'm not sure about the expects vs unwraps however ; given these don't depend on runtime data at all, only on the proper usage of the methods, maybe it would make sense to add debug_assert!
s with a developer-friendly message, and unwrap otherwise (or maybe even use unreachable_unchecked
if that's any useful performance-wise). @kaspar030 wdyt?
What would be the advantage of this compared to using According to the Rust docs about Converting Errors into Panics:
|
I'm somewhat concerned about the binary size, as these |
lgtm! |
9c7f7d3
to
77dae45
Compare
Description
Add some missing documentation about possible panics in
riot-rs-threads
when a function is expected to be called only inside a thread context.Avoid panics where possible through early returns.
Also adds some documentation for
Channel
.Issues/PRs references
Extracted from #381 (comment).
Open Questions
@ROMemories you proposed in feat(threads): sort
ThreadList
by priority #381 (comment) to useNOTE(no-panic)
-style comments to document why anunwrap
can't panic. I've instead usedexpect
, because we a) don't know that it will never panic (it's the callers responsibility) and b) it prints the comment as part of the panic message. Wdyt?This concerns the functions
yield_same
andsleep
. If called from outside a thread context, the operations are now no-ops, instead of causing panics. Do you agree that we should prefer no-ops over panics as long as it doesn't cause any undefined behavior?Change checklist