Show / Hide Table of Contents

Class StackPool<T>

Object pool for System.Collections.Generic.Stack<> instances.

Inheritance
System.Object
ObjectPoolBase<PooledStack<T>>
StackPool<T>
Implements
IObjectPool<PooledStack<T>>
IObjectPoolAllocateFree<PooledStack<T>>
IObjectPoolNew<PooledStack<T>>
Inherited Members
ObjectPoolBase<PooledStack<T>>.Allocate()
ObjectPoolBase<PooledStack<T>>.Free(PooledStack<T>)
ObjectPoolBase<PooledStack<T>>.CreateInstance()
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 size is less than zero.

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 size is less than zero.

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 size is less than zero.

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 size is less than zero.

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.

Implements

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