Struct lifeguard::Pool [] [src]

pub struct Pool<T> where
    T: Recycleable
{ /* fields omitted */ }

A collection of values that can be reused without requiring new allocations.

Pool issues each value wrapped in a smartpointer. When the smartpointer goes out of scope, the wrapped value is automatically returned to the pool.

Methods

impl<T> Pool<T> where
    T: Recycleable
[src]

Creates a pool with size elements of type T allocated.

Creates a pool with size elements of type T allocated and sets a maximum pool size of max_size. Values being added to the pool via Pool::attach or being returned to the pool upon dropping will instead be discarded if the pool is full.

Returns the number of values remaining in the pool.

Returns the maximum number of values the pool can hold.

Removes a value from the pool and returns it wrapped in a `Recycled smartpointer. If the pool is empty when the method is called, a new value will be allocated.

Removes a value from the pool, initializes it using the provided source value, and returns it wrapped in a Recycled smartpointer. If the pool is empty when the method is called, a new value will be allocated.

Associates the provided value with the pool by wrapping it in a Recycled smartpointer.

Removes a value from the pool and returns it without wrapping it in a smartpointer. When the value goes out of scope it will not be returned to the pool.

Removes a value from the pool and returns it wrapped in an RcRecycled smartpointer. If the pool is empty when the method is called, a new value will be allocated.

Removes a value from the pool, initializes it using the provided source value, and returns it wrapped in an RcRecycled smartpointer. If the pool is empty when the method is called, a new value will be allocated.

Associates the provided value with the pool by wrapping it in an RcRecycled smartpointer.