Skip to main content

HugePageVec

Struct HugePageVec 

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

A vector-like allocation that prefers Linux huge pages.

HugePageVec::new initializes every element using T::default() so the returned slices are always valid Rust references.

§Example

use kernelkit::HugePageVec;

let mut values = HugePageVec::<u32>::new(4);
values.as_mut_slice()[2] = 11;
assert_eq!(values.as_slice(), &[0, 0, 11, 0]);

Implementations§

Source§

impl<T> HugePageVec<T>

Source

pub fn len(&self) -> usize

Number of elements in the allocation.

Source

pub fn is_empty(&self) -> bool

Whether the allocation is empty.

Source

pub fn as_slice(&self) -> &[T]

Borrow the allocation as a slice.

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Borrow the allocation as a mutable slice.

Source§

impl<T: Default> HugePageVec<T>

Source

pub fn new_fallible(count: usize) -> Result<Self>

Allocate count initialized elements, preferring huge pages on Linux.

When huge-page allocation is not available, the function falls back to a normal Vec<T>.

Returns Err if the requested size exceeds memory bounds (OOM prevention).

§Errors

Returns an error if the allocation size overflows or cannot be satisfied.

Source

pub fn new(count: usize) -> Self

Allocate count initialized elements, preferring huge pages on Linux.

When huge-page allocation is not available, the function falls back to a normal Vec<T>.

Note: Will panic if the allocation exceeds system bounds. Use new_fallible for strict OOM prevention.

Trait Implementations§

Source§

impl<T: Send> Send for HugePageVec<T>

Source§

impl<T: Sync> Sync for HugePageVec<T>

Auto Trait Implementations§

§

impl<T> Freeze for HugePageVec<T>

§

impl<T> RefUnwindSafe for HugePageVec<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for HugePageVec<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for HugePageVec<T>

§

impl<T> UnwindSafe for HugePageVec<T>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.