pub struct MemoryPool { /* private fields */ }Expand description
Memory pool for efficient allocation/deallocation.
Memory pools amortize allocation costs by maintaining a free list of pre-allocated buffers.
Implementations§
Source§impl MemoryPool
impl MemoryPool
Sourcepub fn new(
name: impl Into<String>,
buffer_size: usize,
max_buffers: usize,
) -> Self
pub fn new( name: impl Into<String>, buffer_size: usize, max_buffers: usize, ) -> Self
Create a new memory pool.
Sourcepub fn allocate(&self) -> PooledBuffer<'_>
pub fn allocate(&self) -> PooledBuffer<'_>
Allocate a buffer from the pool.
Sourcepub fn buffer_size(&self) -> usize
pub fn buffer_size(&self) -> usize
Get buffer size.
Sourcepub fn current_size(&self) -> usize
pub fn current_size(&self) -> usize
Get current pool size.
Sourcepub fn preallocate(&self, count: usize)
pub fn preallocate(&self, count: usize)
Pre-allocate buffers.
Auto Trait Implementations§
impl !Freeze for MemoryPool
impl !RefUnwindSafe for MemoryPool
impl Send for MemoryPool
impl Sync for MemoryPool
impl Unpin for MemoryPool
impl UnwindSafe for MemoryPool
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.