Class ObjectPoolBase<T>
Base class for object pools.
Inheritance
System.Object
ObjectPoolBase<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 |
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. |