-
Notifications
You must be signed in to change notification settings - Fork 186
Simplify WaitGroup
implementation
#958
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
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for salsa-rs canceled.
|
CodSpeed Performance ReportMerging #958 will not alter performanceComparing Summary
|
Is there any other benefit than code size reduction. It seems codspeed doesn't like it at all. |
7a3884e
to
ef1c5dc
Compare
No there isn't. I was curious about the perf impact, I agree this isn't great. Checking if we can actually simplify our impl now |
ef1c5dc
to
1b15e41
Compare
WaitGroup
impl with crossbeam
'sWaitGroup
implementation
Hm, we could get rid of the additional |
@ibraheemdev could you take a look at this PR? |
if let Some(zalsa) = Arc::get_mut(&mut self.handle.zalsa_impl) { | ||
// SAFETY: Polonius when ... https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md#problem-case-3-conditional-control-flow-across-functions | ||
break unsafe { mem::transmute::<&mut Zalsa, &mut Zalsa>(zalsa) }; | ||
} |
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.
if let Some(zalsa) = Arc::get_mut(&mut self.handle.zalsa_impl) { | |
// SAFETY: Polonius when ... https://github.com/rust-lang/rfcs/blob/master/text/2094-nll.md#problem-case-3-conditional-control-flow-across-functions | |
break unsafe { mem::transmute::<&mut Zalsa, &mut Zalsa>(zalsa) }; | |
} | |
if Arc::strong_count(&self.handle.zalsa_impl) == 1 { | |
// SAFETY: The strong count is 1, and we never create any weak pointers, | |
// so we have a unique reference. | |
break unsafe { &mut *(Arc::as_ptr(&self.handle.zalsa_impl) as *mut Zalsa) }; | |
} |
This should avoid the Polonius issue and is a bit cheaper. There is a little question about writing through Arc::as_ptr
, but it is valid in the current implementation and nothing is really blocking it being guaranteed (see rust-lang/rust#104337).
No description provided.