Config

Struct Config 

Source
pub struct Config<T: Default> {
    pub capacity: usize,
    pub prealloc: usize,
    pub auto_reclaim: bool,
    pub surpluspull_threshold_for_reclaim: usize,
    pub idle_threshold_for_surpluspull: usize,
    pub clear_func: Option<fn(&mut T)>,
    /* private fields */
}
Expand description

Configuration for the pool.

Fields§

§capacity: usize

Maximum capacity of the pool.

§prealloc: usize

Number of items to preallocate.

§auto_reclaim: bool

Whether to automatically reclaim allocated items and free them to reduce memory usage.

§surpluspull_threshold_for_reclaim: usize

Threshold of surplus-pull continuous occurrence to trigger reclamation when auto_reclaim is enabled.

§idle_threshold_for_surpluspull: usize

Threshold for idle items to judge as a surplus-pull when auto_reclaim is enabled.

§clear_func: Option<fn(&mut T)>

Optional function to clear or reset an item before it is reused.

Trait Implementations§

Source§

impl<T: Debug + Default> Debug for Config<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Config<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Config<T>

§

impl<T> RefUnwindSafe for Config<T>

§

impl<T> Send for Config<T>

§

impl<T> Sync for Config<T>

§

impl<T> Unpin for Config<T>

§

impl<T> UnwindSafe for Config<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.