Table of Contents

Struct ArrayPoolToken<T>

Namespace
LfrlAnvil.Memory
Assembly
LfrlAnvil.Core.dll

Represents a disposable token that contains a buffer rented from an ArrayPool<T> instance.

public readonly struct ArrayPoolToken<T> : IDisposable

Type Parameters

T

The type of the objects that are in the resource pool.

Implements
Inherited Members
Extension Methods

Properties

ClearArray

Indicates whether the contents of the buffer should be cleared before reuse, when this token gets disposed.

public bool ClearArray { get; }

Property Value

bool

Length

Requested buffer length.

public int Length { get; }

Property Value

int

Pool

Source resource pool.

public ArrayPool<T>? Pool { get; }

Property Value

ArrayPool<T>

Source

Rented buffer.

public T[] Source { get; }

Property Value

T[]

Methods

AsMemory()

Creates a new Memory<T> instance from this token.

[Pure]
public Memory<T> AsMemory()

Returns

Memory<T>

New Memory<T> instance.

AsSpan()

Creates a new Span<T> instance from this token.

[Pure]
public Span<T> AsSpan()

Returns

Span<T>

New Span<T> instance.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()