• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #[cfg(not(all(test, loom)))]
2 pub(crate) mod sync {
3     pub(crate) mod atomic {
4         #[cfg(not(feature = "extra-platforms"))]
5         pub(crate) use core::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
6         #[cfg(feature = "extra-platforms")]
7         pub(crate) use extra_platforms::{AtomicPtr, AtomicUsize, Ordering};
8 
9         pub(crate) trait AtomicMut<T> {
with_mut<F, R>(&mut self, f: F) -> R where F: FnOnce(&mut *mut T) -> R10             fn with_mut<F, R>(&mut self, f: F) -> R
11             where
12                 F: FnOnce(&mut *mut T) -> R;
13         }
14 
15         impl<T> AtomicMut<T> for AtomicPtr<T> {
with_mut<F, R>(&mut self, f: F) -> R where F: FnOnce(&mut *mut T) -> R,16             fn with_mut<F, R>(&mut self, f: F) -> R
17             where
18                 F: FnOnce(&mut *mut T) -> R,
19             {
20                 f(self.get_mut())
21             }
22         }
23     }
24 }
25 
26 #[cfg(all(test, loom))]
27 pub(crate) mod sync {
28     pub(crate) mod atomic {
29         pub(crate) use loom::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
30 
31         pub(crate) trait AtomicMut<T> {}
32     }
33 }
34