pub struct TokenPool<'a> {
tokens: Vec<ZeroToken<'a>>,
index: usize,
}Expand description
Memory pool for token allocation to reduce heap allocations
Fields§
§tokens: Vec<ZeroToken<'a>>Pool of reusable tokens
index: usizeCurrent index in the pool
Implementations§
Source§impl<'a> TokenPool<'a>
impl<'a> TokenPool<'a>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a new token pool with initial capacity
Sourcepub fn get_token(&mut self) -> &mut ZeroToken<'a>
pub fn get_token(&mut self) -> &mut ZeroToken<'a>
Get a token from the pool or create a new one
Sourcepub fn allocated_count(&self) -> usize
pub fn allocated_count(&self) -> usize
Get the number of tokens currently allocated
Sourcepub fn used_count(&self) -> usize
pub fn used_count(&self) -> usize
Get the number of tokens currently in use
Auto Trait Implementations§
impl<'a> Freeze for TokenPool<'a>
impl<'a> RefUnwindSafe for TokenPool<'a>
impl<'a> Send for TokenPool<'a>
impl<'a> Sync for TokenPool<'a>
impl<'a> Unpin for TokenPool<'a>
impl<'a> UnwindSafe for TokenPool<'a>
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