pub struct ConfigPool { /* private fields */ }Expand description
A pool for reusing AnimationConfig instances to reduce allocations
Implementations§
Source§impl ConfigPool
impl ConfigPool
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new config pool with specified initial capacity
Sourcepub fn get_config(&mut self) -> ConfigHandle
pub fn get_config(&mut self) -> ConfigHandle
Gets a config from the pool, creating a new one if none available
Sourcepub fn return_config(&mut self, handle: ConfigHandle)
pub fn return_config(&mut self, handle: ConfigHandle)
Returns a config to the pool for reuse
Sourcepub fn modify_config<F>(&mut self, handle: &ConfigHandle, f: F)where
F: FnOnce(&mut AnimationConfig),
pub fn modify_config<F>(&mut self, handle: &ConfigHandle, f: F)where
F: FnOnce(&mut AnimationConfig),
Modifies a config in the pool safely
Sourcepub fn get_config_ref(&self, handle: &ConfigHandle) -> Option<&AnimationConfig>
pub fn get_config_ref(&self, handle: &ConfigHandle) -> Option<&AnimationConfig>
Gets a reference to a config in the pool
Sourcepub fn in_use_count(&self) -> usize
pub fn in_use_count(&self) -> usize
Gets the number of configs currently in use
Sourcepub fn available_count(&self) -> usize
pub fn available_count(&self) -> usize
Gets the number of configs available in the pool
Sourcepub fn trim_to_size(&mut self, target_size: usize)
pub fn trim_to_size(&mut self, target_size: usize)
Trims the available configs to the specified target size This removes excess configs from the available pool while preserving in-use configs
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ConfigPool
impl RefUnwindSafe for ConfigPool
impl Send for ConfigPool
impl Sync for ConfigPool
impl Unpin for ConfigPool
impl UnwindSafe for ConfigPool
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> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.