Struct scratchpad::CacheAligned [−][src]
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 Clone for CacheAligned
[src]
fn clone(&self) -> CacheAligned
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for CacheAligned
[src]
impl Debug for CacheAligned
[src]
Auto Trait Implementations
impl RefUnwindSafe for CacheAligned
[src]
impl Send for CacheAligned
[src]
impl Sync for CacheAligned
[src]
impl Unpin for CacheAligned
[src]
impl UnwindSafe for CacheAligned
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
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.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut 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.
pub 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>,