Table of Contents

Class ProductionMemoryBuffer

Namespace
DotCompute.Runtime.Services.Memory
Assembly
DotCompute.Runtime.dll

Production memory buffer implementation with comprehensive error handling and performance monitoring.

public sealed class ProductionMemoryBuffer : IUnifiedMemoryBuffer, IAsyncDisposable, IDisposable
Inheritance
ProductionMemoryBuffer
Implements
Inherited Members
Extension Methods

Constructors

ProductionMemoryBuffer(long, long, MemoryOptions, ILogger, nint?, MemoryStatistics)

Initializes a new instance of the ProductionMemoryBuffer class.

public ProductionMemoryBuffer(long id, long sizeInBytes, MemoryOptions options, ILogger logger, nint? pooledHandle, MemoryStatistics statistics)

Parameters

id long

The identifier.

sizeInBytes long

The size in bytes.

options MemoryOptions

The options.

logger ILogger

The logger.

pooledHandle nint?

The pooled handle.

statistics MemoryStatistics

The statistics.

Properties

Id

Gets or sets the id.

public long Id { get; }

Property Value

long

The id.

IsDisposed

Gets or sets a value indicating whether disposed.

public bool IsDisposed { get; }

Property Value

bool

The is disposed.

Options

Gets or sets the options.

public MemoryOptions Options { get; }

Property Value

MemoryOptions

The options.

SizeInBytes

Gets or sets the size in bytes.

public long SizeInBytes { get; }

Property Value

long

The size in bytes.

State

Gets or sets the state.

public BufferState State { get; }

Property Value

BufferState

The state.

Methods

CopyFromAsync<T>(ReadOnlyMemory<T>, long, CancellationToken)

Gets copy from asynchronously.

public ValueTask CopyFromAsync<T>(ReadOnlyMemory<T> source, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

source ReadOnlyMemory<T>

The source.

offset long

The offset.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask

The result of the operation.

Type Parameters

T

The T type parameter.

CopyToAsync<T>(Memory<T>, long, CancellationToken)

Gets copy to asynchronously.

public ValueTask CopyToAsync<T>(Memory<T> destination, long offset = 0, CancellationToken cancellationToken = default) where T : unmanaged

Parameters

destination Memory<T>

The destination.

offset long

The offset.

cancellationToken CancellationToken

The cancellation token.

Returns

ValueTask

The result of the operation.

Type Parameters

T

The T type parameter.

Dispose()

Performs dispose.

public void Dispose()

DisposeAsync()

Gets dispose asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

The result of the operation.