#[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 for CacheAligned<T>where
T: Clone,
impl<T> Clone for CacheAligned<T>where
T: Clone,
Source§fn clone(&self) -> CacheAligned<T>
fn clone(&self) -> CacheAligned<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<T> Copy for CacheAligned<T>where
T: Copy,
Source§impl<T> Debug for CacheAligned<T>where
T: Debug,
impl<T> Debug for CacheAligned<T>where
T: Debug,
Source§impl<T> Default for CacheAligned<T>where
T: Default,
impl<T> Default for CacheAligned<T>where
T: Default,
Source§fn default() -> CacheAligned<T>
fn default() -> CacheAligned<T>
Returns the “default value” for a type. Read more
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 for CacheAligned<T>where
T: Eq,
Source§impl<T> Hash for CacheAligned<T>where
T: Hash,
impl<T> Hash for CacheAligned<T>where
T: Hash,
Source§impl<T> Ord for CacheAligned<T>where
T: Ord,
impl<T> Ord for CacheAligned<T>where
T: Ord,
Source§fn cmp(&self, other: &CacheAligned<T>) -> Ordering
fn cmp(&self, other: &CacheAligned<T>) -> Ordering
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 for CacheAligned<T>where
T: PartialEq,
impl<T> PartialEq for CacheAligned<T>where
T: PartialEq,
Source§impl<T> PartialOrd for CacheAligned<T>where
T: PartialOrd,
impl<T> PartialOrd for CacheAligned<T>where
T: PartialOrd,
Source§impl StateWord for CacheAligned<Atomic<u8>>
impl StateWord for CacheAligned<Atomic<u8>>
impl<T> StructuralPartialEq for CacheAligned<T>where
T: PartialEq,
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