Skip to content

Commit

Permalink
sync::mpsc: reload state after spinning on CAS failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev committed Nov 10, 2022
1 parent 8c17a3e commit 7b721ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions library/std/src/sync/mpmc/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ impl<T> Channel<T> {
token.array.stamp = tail + 1;
return true;
}
Err(t) => {
tail = t;
Err(_) => {
backoff.spin();
tail = self.load(Ordering::Relaxed);
}
}
} else if stamp.wrapping_add(self.one_lap) == tail + 1 {
Expand Down Expand Up @@ -251,8 +251,8 @@ impl<T> Channel<T> {
return true;
}
Err(h) => {
head = h;
backoff.spin();
head = self.head.load(Ordering::Relaxed);
}
}
} else if stamp == head {
Expand Down
10 changes: 5 additions & 5 deletions library/std/src/sync/mpmc/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,10 @@ impl<T> Channel<T> {
token.list.offset = offset;
return true;
},
Err(t) => {
tail = t;
block = self.tail.block.load(Ordering::Acquire);
Err(_) => {
backoff.spin();
tail = self.tail.index.load(Ordering::Acquire);
block = self.tail.block.load(Ordering::Acquire);
}
}
}
Expand Down Expand Up @@ -351,9 +351,9 @@ impl<T> Channel<T> {
return true;
},
Err(h) => {
head = h;
block = self.head.block.load(Ordering::Acquire);
backoff.spin();
head = self.head.index.load(Ordering::Acquire);
block = self.head.block.load(Ordering::Acquire);
}
}
}
Expand Down

0 comments on commit 7b721ed

Please sign in to comment.