Table of Contents

Class PooledBuffer

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

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

manager IPooledBufferService

The buffer manager that owns this buffer.

buffer byte[]

The buffer array.

PooledBuffer(IPooledBufferService, byte[], bool)

Initializes a new instance of the PooledBuffer class.

public PooledBuffer(IPooledBufferService manager, byte[] buffer, bool clearOnReturn)

Parameters

manager IPooledBufferService

The buffer manager that owns this buffer.

buffer byte[]

The buffer array.

clearOnReturn bool

Whether 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

size int

The 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

size int

The minimum size of the buffer.

pool ArrayPool<byte>

The array pool to use.

Properties

Array

Gets the underlying byte array (alias for Buffer).

public byte[] Array { get; }

Property Value

byte[]

The current Array 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

int

The current Length value.

Memory

Gets a Memory<byte> view of the buffer.

public Memory<byte> Memory { get; }

Property Value

Memory<byte>

Size

Gets the size of the buffer.

public int Size { get; }

Property Value

int

The current Size value.

Span

Gets a Span<byte> view of the buffer.

public Span<byte> Span { get; }

Property Value

Span<byte>

Methods

AsMemory()

Gets a memory over the buffer.

public Memory<byte> AsMemory()

Returns

Memory<byte>

A memory over the buffer.

AsSpan()

Gets a span over the buffer.

public Span<byte> AsSpan()

Returns

Span<byte>

A span over the buffer.

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()