[−][src]Struct scratchpad::CacheAligned
Cache-aligned storage for Buffer
and Tracking
use.
Internally, this simply wraps a u8
array to ensure cache alignment.
Arrays and slices of this type can be used directly for either
Scratchpad
storage or marker tracking.
The alignment and size of CacheAligned
are determined by the
CACHE_ALIGNMENT
constant.
Examples
use scratchpad::{CacheAligned, CACHE_ALIGNMENT, Scratchpad}; fn is_cache_aligned<T>(ptr: *const T) -> bool { ptr as usize & (CACHE_ALIGNMENT - 1) == 0 } // `CacheAligned` elements are guaranteed to always be aligned to // `CACHE_ALIGNMENT` bytes, regardless of whether they're created on the // stack, heap-allocated, or allocated from a `Scratchpad`. let cache_aligned = cache_aligned_zeroed!(); assert!(is_cache_aligned(&cache_aligned)); let cache_aligned = Box::new(cache_aligned_zeroed!()); assert!(is_cache_aligned(&*cache_aligned)); let scratchpad = Scratchpad::new( [cache_aligned_zeroed!(); 1], [0usize; 1], ); let marker = scratchpad.mark_front().expect("marker creation failed"); let cache_aligned = marker .allocate(cache_aligned_zeroed!()) .expect("allocation failed"); assert!(is_cache_aligned(&*cache_aligned));
Trait Implementations
impl ByteData for CacheAligned
[src]
impl Copy for CacheAligned
[src]
impl Clone for CacheAligned
[src]
fn clone(&self) -> CacheAligned
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for CacheAligned
[src]
Auto Trait Implementations
impl Sync for CacheAligned
impl Unpin for CacheAligned
impl Send for CacheAligned
impl UnwindSafe for CacheAligned
impl RefUnwindSafe for CacheAligned
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
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>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
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>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,