pub struct MemoryPool { /* private fields */ }Expand description
Memory pool for managing object allocations efficiently
Implementations§
Source§impl MemoryPool
impl MemoryPool
Sourcepub fn with_capacity(
context_nodes: usize,
trie_nodes: usize,
small_vecs: usize,
) -> Self
pub fn with_capacity( context_nodes: usize, trie_nodes: usize, small_vecs: usize, ) -> Self
Create a new memory pool with specified initial capacities
Sourcepub fn get_context_node(&mut self, interner: Arc<StringInterner>) -> ContextNode
pub fn get_context_node(&mut self, interner: Arc<StringInterner>) -> ContextNode
Get a ContextNode from the pool or create a new one
Sourcepub fn return_context_node(&mut self, node: ContextNode)
pub fn return_context_node(&mut self, node: ContextNode)
Return a ContextNode to the pool for reuse
Sourcepub fn get_trie_node(
&mut self,
parent: Option<NodeId>,
state_from_parent: Option<StateId>,
) -> TrieNode
pub fn get_trie_node( &mut self, parent: Option<NodeId>, state_from_parent: Option<StateId>, ) -> TrieNode
Get a TrieNode from the pool or create a new one
Sourcepub fn return_trie_node(&mut self, node: TrieNode)
pub fn return_trie_node(&mut self, node: TrieNode)
Return a TrieNode to the pool for reuse
Sourcepub fn get_small_vec(&mut self) -> SmallVec<[(StateId, usize); 4]>
pub fn get_small_vec(&mut self) -> SmallVec<[(StateId, usize); 4]>
Get a SmallVec from the pool or create a new one
Sourcepub fn return_small_vec(&mut self, vec: SmallVec<[(StateId, usize); 4]>)
pub fn return_small_vec(&mut self, vec: SmallVec<[(StateId, usize); 4]>)
Return a SmallVec to the pool for reuse
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset pool statistics
Sourcepub fn pool_sizes(&self) -> (usize, usize, usize)
pub fn pool_sizes(&self) -> (usize, usize, usize)
Get current pool sizes
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Estimate memory usage of the pool
Trait Implementations§
Source§impl Debug for MemoryPool
impl Debug for MemoryPool
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> 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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more