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>
impl<T> HugePageVec<T>
Source§impl<T: Default> HugePageVec<T>
impl<T: Default> HugePageVec<T>
Sourcepub fn new_fallible(count: usize) -> Result<Self>
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.
Trait Implementations§
impl<T: Send> Send for HugePageVec<T>
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>where
T: RefUnwindSafe + 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