Class ArrayPoolBufferWriter<T>
- Namespace
- CryptoHives.Foundation.Memory.Buffers
- Assembly
- CryptoHives.Foundation.Memory.dll
Helper to build a ReadOnlySequence<T> from a set of buffers. Implements IBufferWriter<T> interface.
public sealed class ArrayPoolBufferWriter<T> : IBufferWriter<T>, IDisposable
Type Parameters
T
- Inheritance
-
ArrayPoolBufferWriter<T>
- Implements
- Inherited Members
Constructors
ArrayPoolBufferWriter()
Initializes a new instance of the ArrayPoolBufferWriter<T> class.
public ArrayPoolBufferWriter()
ArrayPoolBufferWriter(bool, int, int)
Initializes a new instance of the ArrayPoolBufferWriter<T> class.
public ArrayPoolBufferWriter(bool clearArray, int defaultChunksize, int maxChunkSize)
Parameters
ArrayPoolBufferWriter(int, int)
Initializes a new instance of the ArrayPoolBufferWriter<T> class.
public ArrayPoolBufferWriter(int defaultChunksize, int maxChunkSize)
Parameters
Fields
DefaultChunkSize
The default chunk size.
public static readonly int DefaultChunkSize
Field Value
MaxChunkSize
The default maximum chunk size.
public static readonly int MaxChunkSize
Field Value
Methods
Advance(int)
Notifies IBufferWriter<T> that count amount of data was written to Span<T>/Memory<T>
public void Advance(int count)
Parameters
countint
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetMemory(int)
Requests the <xref href="System.Memory%601" data-throw-if-not-resolved="false"></xref> that is at least <code class="paramref">sizeHint</code> in size if possible, otherwise returns maximum available memory.
If <code class="paramref">sizeHint</code> is equal to
0
, currently available memory would get returned.
public Memory<T> GetMemory(int sizeHint = 0)
Parameters
sizeHintint
Returns
- Memory<T>
GetReadOnlySequence()
Get a ReadOnlySequence that represents the written data. The sequence is only valid until the next write operation or until the writer is disposed.
public ReadOnlySequence<T> GetReadOnlySequence()
Returns
GetSpan(int)
Requests the <xref href="System.Span%601" data-throw-if-not-resolved="false"></xref> that is at least <code class="paramref">sizeHint</code> in size if possible, otherwise returns maximum available memory.
If <code class="paramref">sizeHint</code> is equal to
0
, currently available memory would get returned.
public Span<T> GetSpan(int sizeHint = 0)
Parameters
sizeHintint
Returns
- Span<T>