pub struct AlignedPool { /* private fields */ }Expand description
A pre-allocated memory pool with 16-byte alignment guarantee.
Used by AlignedByteSlice to ensure that f32/f64 data mapped from raw
bytes starts on a SIMD-friendly boundary. When source bytes are already
aligned, no copy is needed; when misaligned, a one-time aligned copy is
performed into the pool.
Implementations§
Source§impl AlignedPool
impl AlignedPool
Sourcepub fn new(capacity_bytes: usize) -> Self
pub fn new(capacity_bytes: usize) -> Self
Create a new pool with capacity for at least capacity_bytes of
16-byte-aligned data. The actual allocation may be slightly larger.
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Returns a mutable pointer to the aligned region.
Sourcepub fn is_aligned_16(ptr: *const u8) -> bool
pub fn is_aligned_16(ptr: *const u8) -> bool
Check if a raw pointer is 16-byte aligned.
Sourcepub fn copy_from(&mut self, data: &[u8]) -> Result<(), RuntimeError>
pub fn copy_from(&mut self, data: &[u8]) -> Result<(), RuntimeError>
Copy data into the pool, returning the aligned byte slice.
Returns an error if data exceeds pool capacity.
Sourcepub fn check_alignment(&self) -> bool
pub fn check_alignment(&self) -> bool
Verify that the aligned pointer is indeed 16-byte aligned.
Trait Implementations§
Source§impl Clone for AlignedPool
impl Clone for AlignedPool
Source§fn clone(&self) -> AlignedPool
fn clone(&self) -> AlignedPool
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AlignedPool
impl Debug for AlignedPool
Auto Trait Implementations§
impl Freeze for AlignedPool
impl RefUnwindSafe for AlignedPool
impl Send for AlignedPool
impl Sync for AlignedPool
impl Unpin for AlignedPool
impl UnsafeUnpin for AlignedPool
impl UnwindSafe for AlignedPool
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more