pub struct SizedPool<T: Default> {
head: Option<NonZeroUsize>,
_marker: PhantomData<T>,
}Expand description
A pool allocator that allocates fixed-size blocks.
Fields§
§head: Option<NonZeroUsize>§_marker: PhantomData<T>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> 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