pub struct AllocatorPool { /* private fields */ }Expand description
A thread-safe pool for reusing Allocator instances to reduce allocation overhead.
Internally uses a Vec protected by a Mutex to store available allocators.
Implementations§
Source§impl AllocatorPool
impl AllocatorPool
Sourcepub fn new(size: usize) -> AllocatorPool
pub fn new(size: usize) -> AllocatorPool
Creates a new AllocatorPool pre-filled with the given number of default AllocatorWrapper instances.
Sourcepub fn get(&self) -> AllocatorGuard<'_>
pub fn get(&self) -> AllocatorGuard<'_>
Retrieves an Allocator from the pool, or creates a new one if the pool is empty.
Returns an AllocatorGuard that gives access to the allocator.
§Panics
Panics if the underlying mutex is poisoned.
Trait Implementations§
Source§impl Default for AllocatorPool
impl Default for AllocatorPool
Source§fn default() -> AllocatorPool
fn default() -> AllocatorPool
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for AllocatorPool
impl RefUnwindSafe for AllocatorPool
impl Send for AllocatorPool
impl Sync for AllocatorPool
impl Unpin for AllocatorPool
impl UnwindSafe for AllocatorPool
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