Skip to main content

Module object_pool

Module object_pool 

Source
Expand description

The ObjectPool<C> class is a thread-safe queue that allows concurrent access and is used for reusing allocated objects.

§How this works

The Pool struct can contain objects for which there is at least one implemention of the AsPooled or TryAsPooled trait.

The AsPooled trait is used for types that can be pooled (i.e, created or modified) without supporting failures, while the TryAsPooled trait is used for types that can where creation or modification is fallible.

Structs§

ObjectPool
A thread-safe queue that allows concurrent access and is used for pooling items.
PooledArc
PooledArc<T> is a pooled object wrapper with an Arc to its parent pool.
PooledRef
PooledRef<'a, T> is a pooled object wrapper with a reference to its parent pool.
Undef
An AsPooled initializer for Vec<T>.

Enums§

PoolOption
PoolOption<T> is an enum that can be either a non-pooled item or a pooled item. This is used to allow the user to choose between using a pooled item or opt out of pooling.

Traits§

AsPooled
Retrieve a pooled object from an ObjectPool, creating a new one if the queue is empty.
TryAsPooled
Attempt to retrieve a pooled object from an ObjectPool, creating a new one if the queue is empty.