Class MemoryStreamPool
Object pool for System.IO.MemoryStream instances.
Implements
Inherited Members
Namespace: System.IO
Assembly: Nuqleon.Memory.dll
Syntax
public abstract class MemoryStreamPool : ObjectPoolBase<PooledMemoryStream>, IObjectPool<PooledMemoryStream>, IObjectPoolAllocateFree<PooledMemoryStream>, IObjectPoolNew<PooledMemoryStream>
Constructors
MemoryStreamPool(Int32)
Creates a new System.IO.MemoryStream pool of the specified pool size.
Declaration
protected MemoryStreamPool(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.IO.MemoryStream instances to keep in the pool. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Methods
Create(Int32)
Creates a new System.IO.MemoryStream pool of the specified pool size. The pool creates new instances of System.IO.MemoryStream by calling the default constructor on MemoryStream.
Declaration
public static MemoryStreamPool Create(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.IO.MemoryStream instances to keep in the pool. |
Returns
| Type | Description |
|---|---|
| MemoryStreamPool | Newly created pool for System.IO.MemoryStream instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32)
Creates a new System.IO.MemoryStream pool of the specified pool size.
The pool creates new instances of System.IO.MemoryStream by calling the constructor on System.IO.MemoryStream, passing in the specified capacity.
Declaration
public static MemoryStreamPool Create(int size, int capacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.IO.MemoryStream instances to keep in the pool. |
| System.Int32 | capacity | The initial size of the internal array in bytes. |
Returns
| Type | Description |
|---|---|
| MemoryStreamPool | Newly created pool for System.IO.MemoryStream instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
Create(Int32, Int32, Int32)
Creates a new System.IO.MemoryStream pool of the specified pool size.
The pool creates new instances of System.IO.MemoryStream by calling the constructor on System.IO.MemoryStream, passing in the specified capacity.
Declaration
public static MemoryStreamPool Create(int size, int capacity, int maxCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | size | Number of System.IO.MemoryStream instances to keep in the pool. |
| System.Int32 | capacity | The initial size of the internal array in bytes. |
| System.Int32 | maxCapacity | The maximum capacity allowed for pooled instances. |
Returns
| Type | Description |
|---|---|
| MemoryStreamPool | Newly created pool for System.IO.MemoryStream instances. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentOutOfRangeException | Thrown if |
New()
Gets a holder to a pooled memory stream instance with RAII capabilities to return it to the pool.
Declaration
public PooledMemoryStreamHolder New()
Returns
| Type | Description |
|---|---|
| PooledMemoryStreamHolder | Holder to a pooled memory stream instance. |