Show / Hide Table of Contents

Class ObjectPoolBase<T>

Base class for object pools.

Inheritance
System.Object
ObjectPoolBase<T>
DictionaryPool<TKey, TValue>
HashSetPool<T>
ListPool<T>
QueuePool<T>
StackPool<T>
MemoryStreamPool
ObjectPool<T>
StringBuilderPool
Implements
IObjectPool<T>
IObjectPoolAllocateFree<T>
IObjectPoolNew<T>
Namespace: System.Memory
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class ObjectPoolBase<T> : Object, IObjectPool<T>, IObjectPoolAllocateFree<T>, IObjectPoolNew<T> where T : class
Type Parameters
Name Description
T

Type of the elements stored in the pool.

Constructors

ObjectPoolBase(Int32)

Creates a new object pool of the specified pool size.

Declaration
protected ObjectPoolBase(int size)
Parameters
Type Name Description
System.Int32 size

Number of object instances to keep in the pool.

Exceptions
Type Condition
System.ArgumentOutOfRangeException

Thrown if size is less than zero.

Methods

Allocate()

Returns an object instance and checks it out from the pool.

Declaration
public T Allocate()
Returns
Type Description
T

Object instance returned from the pool.

CreateInstance()

Creates an instance of a pooled object.

Declaration
protected abstract T CreateInstance()
Returns
Type Description
T

Newly created pooled object instance.

Free(T)

Returns an object to the pool.

Declaration
public void Free(T obj)
Parameters
Type Name Description
T obj

Object to return to the pool.

New()

Gets a pooled object instance with RAII capabilities to return it to the pool.

Declaration
public PooledObject<T> New()
Returns
Type Description
PooledObject<T>

Pooled object instance.

Implements

IObjectPool<T>
IObjectPoolAllocateFree<T>
IObjectPoolNew<T>
In This Article
Back to top Generated by DocFX