sync::mpsc: reload state after spinning on CAS failure

This commit is contained in:
Ibraheem Ahmed 2022-10-17 19:30:48 -04:00
parent 8c17a3e7cb
commit 7b721ed0cd
2 changed files with 8 additions and 8 deletions

View file

@ -167,9 +167,9 @@ fn start_send(&self, token: &mut Token) -> bool {
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 {
@ -251,8 +251,8 @@ fn start_recv(&self, token: &mut Token) -> bool {
return true;
}
Err(h) => {
head = h;
backoff.spin();
head = self.head.load(Ordering::Relaxed);
}
}
} else if stamp == head {

View file

@ -246,10 +246,10 @@ fn start_send(&self, token: &mut Token) -> bool {
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);
}
}
}
@ -351,9 +351,9 @@ fn start_recv(&self, token: &mut Token) -> bool {
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);
}
}
}