Class ObjectPool<T>
Instance pool for objects
Inherited Members
Namespace: Unity.XR.CoreUtils
Syntax
public class ObjectPool<T>
where T : class, new()
Type Parameters
Name | Description |
---|---|
T | The type of object to manage instances of |
Fields
PooledQueue
All objects in the pool
Declaration
protected readonly Queue<T> PooledQueue
Field Value
Type | Description |
---|---|
Queue<T> |
Methods
ClearInstance(T)
Implement a clearing function in this in a derived class to have the Recycle(T) method automatically clear the item.
Declaration
protected virtual void ClearInstance(T instance)
Parameters
Type | Name | Description |
---|---|---|
T | instance | The object to return to the pool |
Get()
Get an instance of the object type
Declaration
public virtual T Get()
Returns
Type | Description |
---|---|
T | The object instance |
Recycle(T)
Return an object instance to the pool
Declaration
public void Recycle(T instance)
Parameters
Type | Name | Description |
---|---|---|
T | instance | The instance to return |