Table of Contents

Interface IPooledBufferService

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

Service interface for managing pooled byte buffers using ArrayPool for efficient memory usage.

public interface IPooledBufferService
Extension Methods

Properties

LargestBufferRequested

Gets the largest buffer size requested.

int LargestBufferRequested { get; }

Property Value

int

RentedBuffers

Gets the current number of buffers rented from the pool.

int RentedBuffers { get; }

Property Value

int

Methods

GetStatistics()

Gets buffer usage statistics.

BufferPoolStatistics GetStatistics()

Returns

BufferPoolStatistics

Buffer usage statistics.

RentBuffer(int, bool)

Rents a buffer of at least the specified minimum length.

IDisposablePooledBuffer RentBuffer(int minimumLength, bool clearBuffer = false)

Parameters

minimumLength int

The minimum length of the array needed.

clearBuffer bool

Whether to clear the buffer contents before returning.

Returns

IDisposablePooledBuffer

A disposable pooled buffer that returns to the pool on disposal.

Remarks

The returned buffer implements IDisposablePooledBuffer and must be disposed to return the underlying memory to the pool. Using a using statement or using declaration is recommended.

ReturnBuffer(IPooledBuffer, bool)

Returns a rented buffer to the pool.

void ReturnBuffer(IPooledBuffer buffer, bool clearBuffer = true)

Parameters

buffer IPooledBuffer

The buffer to return.

clearBuffer bool

Whether to clear the buffer contents before returning to pool.