• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use std::fmt;
2 use std::ops::{Deref, DerefMut};
3 
4 /// `AtomicPtr` providing an additional `load_unsync` function.
5 pub(crate) struct AtomicPtr<T> {
6     inner: std::sync::atomic::AtomicPtr<T>,
7 }
8 
9 impl<T> AtomicPtr<T> {
new(ptr: *mut T) -> AtomicPtr<T>10     pub(crate) fn new(ptr: *mut T) -> AtomicPtr<T> {
11         let inner = std::sync::atomic::AtomicPtr::new(ptr);
12         AtomicPtr { inner }
13     }
14 }
15 
16 impl<T> Deref for AtomicPtr<T> {
17     type Target = std::sync::atomic::AtomicPtr<T>;
18 
deref(&self) -> &Self::Target19     fn deref(&self) -> &Self::Target {
20         &self.inner
21     }
22 }
23 
24 impl<T> DerefMut for AtomicPtr<T> {
deref_mut(&mut self) -> &mut Self::Target25     fn deref_mut(&mut self) -> &mut Self::Target {
26         &mut self.inner
27     }
28 }
29 
30 impl<T> fmt::Debug for AtomicPtr<T> {
fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result31     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
32         self.deref().fmt(fmt)
33     }
34 }
35