pub struct SizedPool<T: Default> {
head: Option<NonZeroUsize>,
_marker: PhantomData<T>,
}๐Deprecated: Will be removed soon. Do not use!
Expand description
A pool allocator that allocates fixed-size blocks.
Fieldsยง
ยงhead: Option<NonZeroUsize>๐Deprecated: Will be removed soon. Do not use!
ยง_marker: PhantomData<T>๐Deprecated: Will be removed soon. Do not use!
Implementationsยง
Sourceยงimpl<T: Default> SizedPool<T>
impl<T: Default> SizedPool<T>
Sourceconst fn align_up() -> usize
const fn align_up() -> usize
Calculate the padding required to align the block to align_of::<T>().
Sourcepub unsafe fn add_range(&mut self, range: Range<usize>)
pub unsafe fn add_range(&mut self, range: Range<usize>)
Add a range of blocks to the pool.
range - The range of blocks to add.
ยงSafety
The caller must ensure that the range is valid and that the blocks are at least the size of T + SizedPoolMeta + Padding for T.
Sourceunsafe fn add_block(&mut self, ptr: usize)
unsafe fn add_block(&mut self, ptr: usize)
Add a block to the pool.
ptr - The pointer to the block to add.
ยงSafety
The caller must ensure that the pointer is valid and that the block is at least the size of T + SizedPoolMeta + Padding for T.
Trait Implementationsยง
Auto Trait Implementationsยง
impl<T> Freeze for SizedPool<T>
impl<T> RefUnwindSafe for SizedPool<T>where
T: RefUnwindSafe,
impl<T> Send for SizedPool<T>where
T: Send,
impl<T> Sync for SizedPool<T>where
T: Sync,
impl<T> Unpin for SizedPool<T>where
T: Unpin,
impl<T> UnsafeUnpin for SizedPool<T>
impl<T> UnwindSafe for SizedPool<T>where
T: 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