#[repr(align(128))]pub struct CacheAligned<T>(pub T);Expand description
A wrapper that pushes its value onto its own false-sharing sector.
Aligns the wrapped value to DESTRUCTIVE_INTERFERENCE_SIZE so an atomic
written by one core cannot invalidate a neighbouring atomic written by
another. Because a type’s size is a multiple of its alignment, the wrapper
also occupies that many bytes — which is the point: the padding after the
value is what keeps the next field off this sector.
Structural traits are derived so the wrapper inherits them whenever the
inner T supports them.
Tuple Fields§
§0: TImplementations§
Trait Implementations§
Source§impl<T: Clone> Clone for CacheAligned<T>
impl<T: Clone> Clone for CacheAligned<T>
impl<T: Copy> Copy for CacheAligned<T>
Source§impl<T: Debug> Debug for CacheAligned<T>
impl<T: Debug> Debug for CacheAligned<T>
Source§impl<T: Default> Default for CacheAligned<T>
impl<T: Default> Default for CacheAligned<T>
Source§impl<T> Deref for CacheAligned<T>
impl<T> Deref for CacheAligned<T>
Source§impl<T> DerefMut for CacheAligned<T>
impl<T> DerefMut for CacheAligned<T>
impl<T: Eq> Eq for CacheAligned<T>
Source§impl<T: Hash> Hash for CacheAligned<T>
impl<T: Hash> Hash for CacheAligned<T>
Source§impl<T: Ord> Ord for CacheAligned<T>
impl<T: Ord> Ord for CacheAligned<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<T: PartialEq> PartialEq for CacheAligned<T>
impl<T: PartialEq> PartialEq for CacheAligned<T>
Source§impl<T: PartialOrd> PartialOrd for CacheAligned<T>
impl<T: PartialOrd> PartialOrd for CacheAligned<T>
Source§impl StateWord for CacheAligned<AtomicU8>
impl StateWord for CacheAligned<AtomicU8>
impl<T: PartialEq> StructuralPartialEq for CacheAligned<T>
Auto Trait Implementations§
impl<T> Freeze for CacheAligned<T>where
T: Freeze,
impl<T> RefUnwindSafe for CacheAligned<T>where
T: RefUnwindSafe,
impl<T> Send for CacheAligned<T>where
T: Send,
impl<T> Sync for CacheAligned<T>where
T: Sync,
impl<T> Unpin for CacheAligned<T>where
T: Unpin,
impl<T> UnsafeUnpin for CacheAligned<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CacheAligned<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more