-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Memoryneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration
Milestone
Description
Background and motivation
#27831 added ReadSpan<T> and WriteSpan<T> methods to SafeBuffer, with the explicit intent of surfacing them in UnmanagedMemoryAccessor in a later PR:
The motivation for this is for a later API proposal to add the same methods to
UnmanagedMemoryAccessorwhich will work for memory mapped views.
This was merged 4 years ago, but the later PR appears to have never happened.
API Proposal
Add the following methods to UnmanagedMemoryAccessor:
+ public void ReadSpan<T>(ulong byteOffset, Span<T> buffer) where T : struct
+ public void WriteSpan<T>(ulong byteOffset, ReadOnlySpan<T> data) where T : struct
Their implementations would be similar to the existing ReadArray<T> and WriteArray<T> methods, doing verification and then calling the corresponding methods on _buffer.
API Usage
string text = "Hello, World!";
myMemoryMappedViewAccessor.WriteSpan(MY_OFFSET, text.AsSpan());Alternative Designs
No response
Risks
None that I can see; the underlying APIs were developed specifically for this purpose.
grbell-ms, lostromb, RobSwDev and JakeYallop
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Memoryneeds-further-triageIssue has been initially triaged, but needs deeper consideration or reconsiderationIssue has been initially triaged, but needs deeper consideration or reconsideration