Overview
Exposing a MemoryManager that would make access to memory mapped files easier would help projects interacting with them.
API breakdown
public sealed class SafeBufferMemoryManager : MemoryManager<byte>
{
public SafeBufferMemoryManager(SafeBuffer buffer);
public override Span<byte> GetSpan();
public override MemoryHandle Pin(int elementIndex = 0);
public override void Unpin();
protected override void Dispose(bool disposing);
}
public static class MemoryMappedFileExtensions
{
public static SafeBufferMemoryManager CreateMemoryManager(this MemoryMappedFile file);
public static SafeBufferMemoryManager CreateMemoryManager(this MemoryMappedFile file, long offset, int size);
public static SafeBufferMemoryManager CreateMemoryManager(this MemoryMappedFile file, long offset, int size, MemoryMappedFileAccess access);
}
Usage example
using MemoryMappedFile file = ...;
using SafeBufferMemoryManager memoryManager = file.CreateMemoryManager();
SomeApi(memoryManager.Memory.Span);
Breaking change?
No
Alternatives
dotnet/runtime#37227
Additional context
No response
Help us help you
No, just wanted to propose this
Overview
Exposing a MemoryManager that would make access to memory mapped files easier would help projects interacting with them.
API breakdown
Usage example
Breaking change?
No
Alternatives
dotnet/runtime#37227
Additional context
No response
Help us help you
No, just wanted to propose this