Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/sync_placeholder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,20 @@ impl<
let new_waker = cx.waker();
if !waker.will_wake(new_waker) {
let mut state = shared.state.write();
// Re-check notified after acquiring the lock. A concurrent
Copy link
Owner

Choose a reason for hiding this comment

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

Could you try merging this match arm with the one above, maybe

JoinFutureState::Pending { waker, shared } => loop {
    if this.notified.load(Ordering::Acquire) {
       ..
    }
    ..
    let state = shared.state.write();
    if this.notified.load(Ordering::Acquire) {
        continue;
    }
    ...
}

// insert may have drained the waiters list between the
// notified check in the match guard above and this point.
if this.notified.load(Ordering::Acquire) {
drop(state);
let JoinFutureState::Pending { shared, .. } =
mem::replace(&mut this.state, JoinFutureState::Done)
else {
unsafe { unreachable_unchecked() }
};
return Poll::Ready(PlaceholderGuard::handle_notification(
lifecycle, shard, shared,
));
}
if let Some(w) = state
.waiters
.iter_mut()
Expand Down