Class PooledMemoryBufferArea
Manage a collection of pooled memory buffers such that it is convenient to read and write to it, as if it was one large contiguous area.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.BaseLibrary
Assembly: EPiServer.BaseLibrary.dll
Version: 8.11.0Syntax
public class PooledMemoryBufferArea : IDisposable
Constructors
PooledMemoryBufferArea(MemoryBufferPool)
Initializes a new instance of the PooledMemoryBufferArea class.
Declaration
public PooledMemoryBufferArea(MemoryBufferPool pool)
Parameters
Type | Name | Description |
---|---|---|
MemoryBufferPool | pool | The pool. |
Fields
buffers
The list of buffers representing the total memory area. No assumption is made on the size of each and every buffer.
Declaration
protected ArrayList buffers
Field Value
Type | Description |
---|---|
System.Collections.ArrayList |
currentBufferIndex
The index into _buffers for the current buffer (or -1 if not set)
Declaration
protected int currentBufferIndex
Field Value
Type | Description |
---|---|
System.Int32 |
currentBufferOffset
The offset of the current buffer as defined by currentBufferIndex
Declaration
protected int currentBufferOffset
Field Value
Type | Description |
---|---|
System.Int32 |
currentBufferPosition
The offset into the current buffer as defined by currentBufferIndex
Declaration
protected long currentBufferPosition
Field Value
Type | Description |
---|---|
System.Int64 |
pool
The MemoryBufferPool where we allocate memory from (and release it when we're disposed).
Declaration
protected MemoryBufferPool pool
Field Value
Type | Description |
---|---|
MemoryBufferPool |
poolSize
The total capacity of the current pool
Declaration
protected long poolSize
Field Value
Type | Description |
---|---|
System.Int64 |
Methods
Dispose()
Does a release of the buffers to the MemoryPool for potential re-use.
Declaration
public void Dispose()
Dispose(Boolean)
You should call Dispose() from your code (which will call here) to ensure that memory buffers are returned correctly to the pool. If this object is not explicitly disposed, the buffers will not be re-used by the pool (but will instead be taken by the garbage collector - no leak occurs).
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true when called from code, false when called by GC |
Finalize()
Releases unmanaged resources and performs other cleanup operations before the PooledMemoryBufferArea is reclaimed by garbage collection.
Declaration
protected void Finalize()
Read(Int64, Byte[], Int32, Int32)
Reads a buffer of data at the specified position.
Declaration
public virtual int Read(long position, byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | The position. |
System.Byte[] | buffer | The buffer. |
System.Int32 | offset | The offset. |
System.Int32 | count | The count. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes actually read |
Exceptions
Type | Condition |
---|---|
ArgumentException |
ReadOrWrite(Int64, Byte[], Int32, Int32, PooledMemoryBufferArea.BlockCopyDelegate)
Read or Write at a specified location in the buffer list. We maintain state between calls to optimize the typical case of sequential writing followed by sequential reading. This also allows a stream implementation using this as backing store to manage it's position witout any side effects until data is actually written.
Declaration
protected int ReadOrWrite(long position, byte[] buffer, int offset, int count, PooledMemoryBufferArea.BlockCopyDelegate blockCopy)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | The position. |
System.Byte[] | buffer | The buffer. |
System.Int32 | offset | The offset. |
System.Int32 | count | The count. |
PooledMemoryBufferArea.BlockCopyDelegate | blockCopy | The block copy delegate determining if we're reading to the parameter buffer or writing to it. |
Returns
Type | Description |
---|---|
System.Int32 |
Write(Int64, Byte[], Int32, Int32)
Writes a buffer of data at the specified position.
Declaration
public virtual int Write(long position, byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | The position. |
System.Byte[] | buffer | The buffer. |
System.Int32 | offset | The offset. |
System.Int32 | count | The count. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes actually written |
Exceptions
Type | Condition |
---|---|
ArgumentException |