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
idlongThe identifier.
sizeInByteslongThe size in bytes.
optionsMemoryOptionsThe options.
loggerILoggerThe logger.
pooledHandlenint?The pooled handle.
statisticsMemoryStatisticsThe 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
sourceReadOnlyMemory<T>The source.
offsetlongThe offset.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- ValueTask
The result of the operation.
Type Parameters
TThe 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
destinationMemory<T>The destination.
offsetlongThe offset.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- ValueTask
The result of the operation.
Type Parameters
TThe T type parameter.
Dispose()
Performs dispose.
public void Dispose()
DisposeAsync()
Gets dispose asynchronously.
public ValueTask DisposeAsync()
Returns
- ValueTask
The result of the operation.