Skip to content
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

counter: use NonNull #1078

Merged
merged 1 commit into from
Jan 22, 2024
Merged

counter: use NonNull #1078

merged 1 commit into from
Jan 22, 2024

Conversation

calebsander
Copy link
Contributor

counter::{Sender, Receiver} hold shared references to a channel, similar to an Arc. Their raw pointers to the Counter are never null, so change them from *mut Counter<C> to NonNull<Counter<C>>. This makes it easier to verify the safety requirements for dereferences, and allows the niche value optimization to apply.

counter::{Sender, Receiver} hold shared references to a channel,
similar to an Arc. Their raw pointers to the Counter are never null,
so change them from *mut Counter<C> to NonNull<Counter<C>>.
This makes it easier to verify the safety requirements for dereferences,
and allows the niche value optimization to apply.
Copy link
Member

@taiki-e taiki-e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Considering our use case, I don't think niche optimization will be used, but it would indeed somewhat clarify the code.

@taiki-e taiki-e merged commit e316b3e into crossbeam-rs:master Jan 22, 2024
23 checks passed
@calebsander calebsander deleted the refactor/counter-nonnull branch November 17, 2024 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants