Skip to content

Consider adding MemoryMarshal.GetOwner(ROM) #25082

@benaadams

Description

@benaadams
public static partial class MemoryMarshal
{
    public static object GetOwner(ReadOnlyMemory<T> readOnlyMemory)
}

With Registered IO; when sending an receiving data the api doesn't use address, offset, length; it uses id, offset, length

The ids are assigned upfront when you register the addresses (once)

Currently you have to loop through all the registered memory blocks to find which one matches and then get its id which is inefficient and also has to protect against concurrency of new memory being registered while its searching.

This search and registration blocking could be avoided with the new api

if (GetOwner(readOnlyMemory) is RioMemoryPoolBlock block)
{
    var idToUse = block.Id;
}
else
{
    // Not registered memory, get registered memory block and copy data
}

/cc @davidfowl @KrzysztofCwalina

Metadata

Metadata

Labels

api-approvedAPI was approved in API review, it can be implementedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-System.Memoryhelp wanted[up-for-grabs] Good issue for external contributors

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions