pub struct MemoryPool<T> { /* private fields */ }Expand description
Memory pool structure
Implementations§
Source§impl<T: Recycle> MemoryPool<T>
impl<T: Recycle> MemoryPool<T>
Sourcepub fn create_with(
size: usize,
max: usize,
creator: CreateFn<T>,
) -> MemoryPool<T>
pub fn create_with( size: usize, max: usize, creator: CreateFn<T>, ) -> MemoryPool<T>
Constructor, must take intial size and maximum size. The creator closure is used to initialize the mem slots
§Panics
This function will panic if size > max
Sourcepub fn get(&self) -> ArcRecycled<T>
pub fn get(&self) -> ArcRecycled<T>
This function returns a memory slot from the memory pool
§Panics
This function will panic if it needs to allocate more than max
Sourcepub fn try_get(&self) -> Option<ArcRecycled<T>>
pub fn try_get(&self) -> Option<ArcRecycled<T>>
This function returns a memory slot from the memory pool if size does not exceed max. returns None otherwise
Auto Trait Implementations§
impl<T> !Freeze for MemoryPool<T>
impl<T> !RefUnwindSafe for MemoryPool<T>
impl<T> !Send for MemoryPool<T>
impl<T> !Sync for MemoryPool<T>
impl<T> Unpin for MemoryPool<T>
impl<T> !UnwindSafe for MemoryPool<T>
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