2019-11-13 14:55:25 -08:00
|
|
|
#[cfg(not(all(test, loom)))]
|
2019-10-16 09:53:36 -07:00
|
|
|
pub(crate) mod sync {
|
|
|
|
|
pub(crate) mod atomic {
|
|
|
|
|
pub(crate) use core::sync::atomic::{fence, AtomicPtr, AtomicUsize, Ordering};
|
2020-05-21 19:23:22 -07:00
|
|
|
|
|
|
|
|
pub(crate) trait AtomicMut<T> {
|
|
|
|
|
fn with_mut<F, R>(&mut self, f: F) -> R
|
|
|
|
|
where
|
|
|
|
|
F: FnOnce(&mut *mut T) -> R;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T> AtomicMut<T> for AtomicPtr<T> {
|
|
|
|
|
fn with_mut<F, R>(&mut self, f: F) -> R
|
|
|
|
|
where
|
|
|
|
|
F: FnOnce(&mut *mut T) -> R,
|
|
|
|
|
{
|
|
|
|
|
f(self.get_mut())
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-16 09:53:36 -07:00
|
|
|
}
|
|
|
|
|
}
|
2019-11-13 14:55:25 -08:00
|
|
|
|
|
|
|
|
#[cfg(all(test, loom))]
|
2020-05-21 19:23:22 -07:00
|
|
|
pub(crate) mod sync {
|
|
|
|
|
pub(crate) mod atomic {
|
|
|
|
|
pub(crate) use loom::sync::atomic::{fence, AtomicPtr, AtomicUsize, Ordering};
|
|
|
|
|
|
|
|
|
|
pub(crate) trait AtomicMut<T> {}
|
|
|
|
|
}
|
|
|
|
|
}
|