1
Fork 0

rustc_metadata: use configurable AtomicBool for privateness flag

This switches to using a `Cell` for single-threaded rustc.
This commit is contained in:
Michael Howell 2023-05-08 15:12:45 -07:00
parent b537c1f175
commit a12f50ddc4
2 changed files with 16 additions and 2 deletions

View file

@ -143,6 +143,20 @@ cfg_if! {
self.0.set(val);
result
}
pub fn fetch_update(
&self,
_order_set: Ordering,
_order_get: Ordering,
mut f: impl FnMut(bool) -> Option<bool>,
) -> Result<bool, bool> {
let prev = self.0.get();
if let Some(next) = f(prev) {
self.0.set(next);
Ok(prev)
} else {
Err(prev)
}
}
}
impl<T: Copy + PartialEq> Atomic<T> {