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(thread_count: usize) -> AllocatorPool
pub fn new(thread_count: usize) -> AllocatorPool
Creates a new AllocatorPool for use across the specified number of threads.
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.
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