Class PooledBuffer
Represents a buffer that is rented from an array pool.
public sealed class PooledBuffer : IDisposablePooledBuffer, IPooledBuffer, IDisposable
- Inheritance
-
PooledBuffer
- Implements
- Inherited Members
- Extension Methods
Constructors
PooledBuffer(IPooledBufferService, byte[])
Initializes a new instance of the PooledBuffer class.
public PooledBuffer(IPooledBufferService manager, byte[] buffer)
Parameters
managerIPooledBufferServiceThe buffer manager that owns this buffer.
bufferbyte[]The buffer array.
PooledBuffer(IPooledBufferService, byte[], bool)
Initializes a new instance of the PooledBuffer class.
public PooledBuffer(IPooledBufferService manager, byte[] buffer, bool clearOnReturn)
Parameters
managerIPooledBufferServiceThe buffer manager that owns this buffer.
bufferbyte[]The buffer array.
clearOnReturnboolWhether to clear the buffer when returning to the pool.
PooledBuffer(int)
Initializes a new instance of the PooledBuffer class using the shared array pool.
public PooledBuffer(int size)
Parameters
sizeintThe minimum size of the buffer.
PooledBuffer(int, ArrayPool<byte>)
Initializes a new instance of the PooledBuffer class using the specified array pool.
public PooledBuffer(int size, ArrayPool<byte> pool)
Parameters
Properties
Array
Gets the underlying byte array (alias for Buffer).
public byte[] Array { get; }
Property Value
Buffer
Gets the buffer array.
public byte[] Buffer { get; }
Property Value
- byte[]
Exceptions
- ObjectDisposedException
Thrown if the buffer has been disposed.
Length
Gets the length of the buffer (alias for Size).
public int Length { get; }
Property Value
Memory
Gets a Memory<byte> view of the buffer.
public Memory<byte> Memory { get; }
Property Value
Size
Gets the size of the buffer.
public int Size { get; }
Property Value
Span
Gets a Span<byte> view of the buffer.
public Span<byte> Span { get; }
Property Value
Methods
AsMemory()
Gets a memory over the buffer.
public Memory<byte> AsMemory()
Returns
AsSpan()
Gets a span over the buffer.
public Span<byte> AsSpan()
Returns
Dispose()
Disposes the buffer and returns it to the pool. Safe to call more than once, and safe to call from more than one thread: the buffer is returned exactly once.
public void Dispose()