Class PooledBufferWriter<T>
Represents memory writer that uses pooled memory.
Implements
Inherited Members
Namespace: DotNext.Buffers
Assembly: DotNext.dll
Syntax
public sealed class PooledBufferWriter<T> : MemoryWriter<T>, IBufferWriter<T>, IConvertible<ReadOnlyMemory<T>>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, IGrowableBuffer<T>, IDisposable
Type Parameters
| Name | Description |
|---|---|
| T | The data type that can be written. |
Constructors
| Improve this Doc View SourcePooledBufferWriter(MemoryAllocator<T>)
Initializes a new writer with the default initial capacity.
Declaration
public PooledBufferWriter(MemoryAllocator<T> allocator = null)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryAllocator<T> | allocator | The allocator of internal buffer. |
PooledBufferWriter(MemoryAllocator<T>, Int32)
Initializes a new writer with the specified initial capacity.
Declaration
public PooledBufferWriter(MemoryAllocator<T> allocator, int initialCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryAllocator<T> | allocator | The allocator of internal buffer. |
| Int32 | initialCapacity | The initial capacity of the writer. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
Properties
| Improve this Doc View SourceCapacity
Gets the total amount of space within the underlying memory.
Declaration
public override int Capacity { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | This writer has been disposed. |
WrittenMemory
Gets the data written to the underlying buffer so far.
Declaration
public override ReadOnlyMemory<T> WrittenMemory { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyMemory<T> |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | This writer has been disposed. |
Methods
| Improve this Doc View SourceClear()
Clears the data written to the underlying buffer.
Declaration
public override void Clear()
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | This writer has been disposed. |
Clear(Boolean)
Clears the data written to the underlying memory.
Declaration
public override void Clear(bool reuseBuffer)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | reuseBuffer | true to reuse the internal buffer; false to destroy the internal buffer. |
Overrides
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | This writer has been disposed. |
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| Boolean | disposing |
Overrides
GetMemory(Int32)
Returns the memory to write to that is at least the requested size.
Declaration
public override Memory<T> GetMemory(int sizeHint = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | sizeHint | The minimum length of the returned memory. |
Returns
| Type | Description |
|---|---|
| Memory<T> | The memory block of at least the size |
Overrides
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | The requested buffer size is not available. |
| ObjectDisposedException | This writer has been disposed. |