use `get_mut` in `flavors::array::Channel::drop`
As access to `&mut self` in `Drop` impls gives exclusive access, it's
unnecessary to atomically load `self.head` and `self.tail` there.
@@ -521,10 +521,21 @@ impl<T> Channel<T> {
impl<T> Drop for Channel<T> {
fn drop(&mut self) {
// Get the index of the head.
- let hix = self.head.load(Ordering::Relaxed) & (self.mark_bit - 1);
+ let hix = *self.head.get_mut() & (self.mark_bit - 1);
+ let tix = *self.tail.get_mut() & (self.mark_bit - 1);
+
+ let len = if hix < tix {
+ tix - hix
+ } else if hix > tix {
+ self.cap - hix + tix
+ } else if (tail & !self.mark_bit) == head {
+ 0
+ } else {
+ self.cap
+ };
// Loop over all slots that hold a message and drop them.
- for i in 0..self.len() {
+ for i in 0..len {
// Compute the index of the next slot holding a message.
let index = if hix + i < self.cap {
hix + i
