Skip to main content

BatchStreamObjectPool

Struct BatchStreamObjectPool 

Source
pub struct BatchStreamObjectPool<T> { /* private fields */ }
Expand description

A pool of fixed-size arrays of optional object references.

Implementations§

Source§

impl<T> BatchStreamObjectPool<T>

Source

pub const DEFAULT_ARRAY_SIZE: usize = 128

The array size used when none is specified.

Source

pub fn new( reclaim_immediately: bool, array_size: usize, start_timer: Option<BatchStreamPoolStartTimer>, ) -> Self

Source

pub fn array_size(&self) -> usize

Methods from Deref<Target = BatchStreamPoolBase<Box<[Option<T>]>, BatchStreamObjectPoolItems<T>>>§

Source

pub fn current_usage(&self) -> i32

The number of items currently handed out.

Source

pub fn current_pool(&self) -> i32

The number of items currently kept in the pool.

Source

pub fn timer_is_running(&self) -> bool

Whether the owner is expected to call update_timer_tick once per second.

Source

pub fn update_timer_tick(&self) -> bool

The timer procedure: trims the pool down to the number of items that were in use at the same time during the last 10 ticks (but keeps at least 10), and advances the usage statistics.

To be called by the owner once per second while the timer is running. Returns whether the timer keeps running.

Source

pub fn get(&self) -> T

Takes an item from the pool, creating one when the pool is empty.

Source

pub fn return_item(&self, item: T)

Gives an item back (C# Return). The item is cleared, and then kept for reuse unless the pool is disposed or reclaims immediately.

Source

pub fn dispose(&self)

Destroys the pooled items; items returned from now on are destroyed instead of being kept.

Trait Implementations§

Source§

impl<T> Deref for BatchStreamObjectPool<T>

Source§

type Target = BatchStreamPoolBase<Box<[Option<T>]>, BatchStreamObjectPoolItems<T>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.