Condividi tramite


MemoryOwner Class

Definition

IMemoryOwner<T> wrapper which indicates the number of bytes in Memory which contain valid data. When performing reads, consumers of this class should consider ValidLength) as the length of Memory rather than using Length directly.

public class MemoryOwner : IDisposable, System.Buffers.IMemoryOwner<byte>
type MemoryOwner = class
    interface IMemoryOwner<byte>
    interface IDisposable
Public Class MemoryOwner
Implements IDisposable, IMemoryOwner(Of Byte)
Inheritance
MemoryOwner
Implements

Remarks

This class is used in place of IMemoryOwner<T> directly, as Rent(Int32) may return a IMemoryOwner<T> with Memory with a Length greater than the size requested.

Constructors

MemoryOwner(ArraySegment<Byte>)

Initializes a new instance of the MemoryOwner class with the specified ArraySegment<T>. Count will be used as the initial value for ValidLength.

MemoryOwner(Byte[], Int32)

Initializes a new instance of the MemoryOwner class with the specified byte[] and valid length.

MemoryOwner(IMemoryOwner<Byte>, Int32)

Initializes a new instance of the MemoryOwner class with the specified IMemoryOwner<T> and valid length.

Fields

ValidLength

The number of bytes containing data in Memory. When performing reads, consumers of this class should consider ValidLength as the length of Memory rather than using Length directly.

Properties

Memory

See Memory.

Methods

Dispose()

Dispose the wrapped IMemoryOwner<T>.

Dispose(Boolean)

If disposing is true, dispose the wrapped IMemoryOwner<T> instance.

Applies to