Use a simpler atomic operation than the compare_exchange hammer

This commit is contained in:
Oli Scherer 2023-03-15 16:25:28 +00:00
parent 300901b705
commit 54214c8d8d
2 changed files with 9 additions and 3 deletions

View file

@ -107,6 +107,14 @@ cfg_if! {
}
}
impl Atomic<bool> {
pub fn fetch_or(&self, val: bool, _: Ordering) -> bool {
let result = self.0.get() | val;
self.0.set(val);
result
}
}
impl<T: Copy + PartialEq> Atomic<T> {
#[inline]
pub fn compare_exchange(&self,