Class StackPool<T>
Object pool for System.Collections.Generic.Stack<> instances.
Implements
Inherited Members
Namespace: System.Collections.Generic
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class StackPool<T> : ObjectPoolBase<PooledStack<T>>, IObjectPool<PooledStack<T>>, IObjectPoolAllocateFree<PooledStack<T>>, IObjectPoolNew<PooledStack<T>>
Type Parameters
Name | Description |
---|---|
T | Specifies the type of elements in the stack. |
Constructors
StackPool(Int32)
Creates a new System.Collections.Generic.Stack<> pool of the specified pool size.
Declaration
protected StackPool(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | Number of System.Collections.Generic.Stack<> instances to keep in the pool. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if |
Methods
Create(Int32)
Creates a new System.Collections.Generic.Stack<> pool of the specified pool size. The pool creates new instances of System.Collections.Generic.Stack<> by calling the default constructor on Stack{T}.
Declaration
public static StackPool<T> Create(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | Number of System.Collections.Generic.Stack<> instances to keep in the pool. |
Returns
Type | Description |
---|---|
StackPool<T> | Newly created pool for System.Collections.Generic.Stack<> instances. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32)
Creates a new System.Collections.Generic.Stack<> pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.Stack<> by calling the constructor on System.Collections.Generic.Stack<>, passing in the specified capacity
.
Declaration
public static StackPool<T> Create(int size, int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | Number of System.Collections.Generic.Stack<> instances to keep in the pool. |
System.Int32 | capacity | The initial number of elements that the System.Collections.Generic.Stack<> can contain. |
Returns
Type | Description |
---|---|
StackPool<T> | Newly created pool for System.Collections.Generic.Stack<> instances. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32, Int32)
Creates a new System.Collections.Generic.Stack<> pool of the specified pool size.
The pool creates new instances of System.Collections.Generic.Stack<> by calling the constructor on System.Collections.Generic.Stack<>, passing in the specified capacity
.
Declaration
public static StackPool<T> Create(int size, int capacity, int maxCapacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | Number of System.Collections.Generic.Stack<> instances to keep in the pool. |
System.Int32 | capacity | The initial number of elements that the System.Collections.Generic.Stack<> can contain. |
System.Int32 | maxCapacity | The maximum capacity allowed for pooled instances. |
Returns
Type | Description |
---|---|
StackPool<T> | Newly created pool for System.Collections.Generic.Stack<> instances. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown if |
New()
Gets a holder to a pooled stack instance with RAII capabilities to return it to the pool.
Declaration
public PooledStackHolder<T> New()
Returns
Type | Description |
---|---|
PooledStackHolder<T> | Holder to a pooled stack instance. |