⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

CacheAligned

Struct CacheAligned 

Source
pub struct CacheAligned<T> { /* private fields */ }
Expand description

Cache-line-aligned wrapper type for eliminating false sharing.

Wraps a value T and ensures it is aligned to a full cache line boundary (64 bytes). When placed in arrays or adjacent to other per-CPU data, this prevents false sharing between cores.

§Example

use crate::mm::cache_aligned::CacheAligned;
use core::sync::atomic::{AtomicU64, Ordering};

// Each counter occupies its own cache line
static COUNTERS: [CacheAligned<AtomicU64>; 4] = [
    CacheAligned::new(AtomicU64::new(0)),
    CacheAligned::new(AtomicU64::new(0)),
    CacheAligned::new(AtomicU64::new(0)),
    CacheAligned::new(AtomicU64::new(0)),
];

Implementations§

Source§

impl<T> CacheAligned<T>

Source

pub const fn new(value: T) -> Self

Create a new cache-line-aligned wrapper.

Source

pub fn into_inner(self) -> T

Consume the wrapper and return the inner value.

Trait Implementations§

Source§

impl<T: Clone> Clone for CacheAligned<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for CacheAligned<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for CacheAligned<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> DerefMut for CacheAligned<T>

Source§

fn deref_mut(&mut self) -> &mut T

Mutably dereferences the value.
Source§

impl<T> Deref for CacheAligned<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T: Copy> Copy for CacheAligned<T>

Source§

impl<T: Send> Send for CacheAligned<T>

Source§

impl<T: Sync> Sync 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> Unpin for CacheAligned<T>
where T: Unpin,

§

impl<T> UnwindSafe for CacheAligned<T>
where T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.