-
-
Notifications
You must be signed in to change notification settings - Fork 851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System.Memory API integration #565
Comments
I'd really like to see these, as a consumer of this library. I recognize that in most cases you're going to have to just copy the span to an array (at least you can ArrayPool) to use with MemoryStream, but eventually (.NET Standard 3, apparently) streams will be able to read from Spans directly.
|
@jherby2k I like your API proposal pretty much, we should implement it. Our current docs on
|
@antonfirsov @JimBobSquarePants Additional info on Span and Memory stuff: |
Well I alluded to that in my request... at the time it was announced that the spanified Steams would be coming to netstandard 3.0 / .net 4.8 but now it sounds like that isn’t going to be the case. My suggestion is to start targeting netcoreapp2.1 directly, and for netstandard just copy the span to a buffer from the array pool. At least then the API is consistent, even if there is no performance benefit when using the netstandard lib. |
@jherby2k unfortunately, "spanified stream" isn't a thing that helps here, but I figured it out! Gonna PR it soon. |
Did not know about that one! That’s great.
Just to clarify though, by “spanified stream” I’m referring to .net core 2.1’s Stream.Write(Span<byte> buffer) overload. Which is exactly what you’re looking for, but obviously isn’t available for .net standard.
|
@jherby2k ahh, you mean creating a |
We may need to introduce further API changes to allow handling very large unmanaged buffers and memory mapped files, but the topic is not yet clear for me. I'm leaving a few links here, so we can find them later:
|
Best System.Memory article so far: |
All tasks are done, so I'm closing this epic. |
Goals
Thanks to #558, we are now able to expose
System.Memory
API-s allowing efficient interop operations. However, we need to distinguish between different use-cases, because they raise design problems of different difficulty levels. In some use-cases we have to decide whether we should exposeSpan<T>
,Memory<T>
or both."Official" guideline on System.Memory
Managed to find a WIP (?) documentation on
Memory<T>
. (It was mentioned in coreclr/#17340)Tasks
ReadOnlySpan<T>
overloads of LoadPixelData (done in Expose Span methods on LoadPixelData and SavePixelData #567)ReadOnlySpan<T>
overloads forImage.Load()
andImage.DetectFormat()
. See @jherby2k's proposal.UnmanagedMemoryStream
for this.System.Memory.IMemoryOwner<T>
and/orSystem.Memory.MemoryManager<T>
withSL.ImageSharp.Memory.IBuffer<T>
Memory<T>
, thus for the following 2 pointsNotice the name collision withUPDATE: SixLabors stuff is now calledSL.ImageSharp.Memory.MemoryManager<T>
:PMemoryAllocator
Image.Wrap(existingMemoryArea)
or similar.Already added as internal, need to validate the API through a real-life use-case.DONEimage.GetPixelSpan()
andimage.GetPixelRowSpan()
image.GetPixelSpan()
andimage.GetPixelRowSpan()
Memory<T>
for nowThe text was updated successfully, but these errors were encountered: