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

channel: use AtomicUsize::get_mut in flavors::{array,list}::Channel::drop #811

Merged
merged 3 commits into from
Apr 11, 2022

Conversation

eb-64-64
Copy link
Contributor

@eb-64-64 eb-64-64 commented Apr 6, 2022

As access to &mut self in Drop impls gives exclusive access, it's
unnecessary to atomically load self.head and self.tail there.

As access to `&mut self` in `Drop` impls gives exclusive access, it's
unnecessary to atomically load `self.head` and `self.tail` there.
@eb-64-64
Copy link
Contributor Author

eb-64-64 commented Apr 6, 2022

I stumbled across this as I was reading the code for educational purposes

@eb-64-64 eb-64-64 changed the title crossbeam-channel: use AtomicUsize::get_mut in flavors::array::Channel::drop channel: use AtomicUsize::get_mut in flavors::array::Channel::drop Apr 6, 2022
@eb-64-64 eb-64-64 changed the title channel: use AtomicUsize::get_mut in flavors::array::Channel::drop channel: use AtomicUsize::get_mut in flavors::{array,list}::Channel::drop Apr 7, 2022
@taiki-e
Copy link
Member

taiki-e commented Apr 8, 2022

Thanks! I'll merge this once the upstream bugfix (rust-lang/rust#95621) which fixes the breakage on miri CI merged.

@RalfJung
Copy link
Contributor

RalfJung commented Apr 9, 2022

You could temporarily remove the -Zmiri-check-number-validity to work around the MPSC bug.
(Sorry for this, I didn't realize how widely used that flag is so I wasn't too worried when I noticed MPSC breaking with it.)

@taiki-e
Copy link
Member

taiki-e commented Apr 11, 2022

Thanks for the advice. This time I chose to wait for the patch to be merged since it had already been submitted that looked reasonable. It makes sense to temporarily remove the flag if the fix is going to take a long time.

@taiki-e
Copy link
Member

taiki-e commented Apr 11, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 11, 2022

Build succeeded:

@bors bors bot merged commit df9b0c9 into crossbeam-rs:master Apr 11, 2022
@eb-64-64 eb-64-64 deleted the mut_drop branch April 12, 2022 01:56
bors bot added a commit that referenced this pull request Jul 21, 2022
874: Use get_mut instead of atomic load in Drop impls r=taiki-e a=taiki-e

Similar to #811, but for deque and queue.

Co-authored-by: Taiki Endo <[email protected]>
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.

3 participants