- WritableRegion: enable wrapping IMemoryOwner<byte>
- IVirtualMemoryManager impls of GetWritableRegion() use pooled memory when region is non-contiguous. - IVirtualMemoryManager: add GetReadOnlySequence() and impls - ByteMemoryPool: add new method RentCopy() - ByteMemoryPool: make class static, remove ctor and singleton field from earlier impl
This commit is contained in:
parent
8c2da1aa04
commit
508a850c54
1 changed files with 26 additions and 0 deletions
26
src/Ryujinx.Common/Memory/BytesReadOnlySequenceSegment.cs
Normal file
26
src/Ryujinx.Common/Memory/BytesReadOnlySequenceSegment.cs
Normal file
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
|
||||
namespace Ryujinx.Common.Memory
|
||||
{
|
||||
/// <summary>
|
||||
/// A concrete implementation of <seealso cref="ReadOnlySequence{T}"/>,
|
||||
/// with methods to help build a full sequence.
|
||||
/// </summary>
|
||||
public sealed class BytesReadOnlySequenceSegment : ReadOnlySequenceSegment<byte>
|
||||
{
|
||||
public BytesReadOnlySequenceSegment(Memory<byte> memory) => Memory = memory;
|
||||
|
||||
public BytesReadOnlySequenceSegment Append(Memory<byte> memory)
|
||||
{
|
||||
var nextSegment = new BytesReadOnlySequenceSegment(memory)
|
||||
{
|
||||
RunningIndex = RunningIndex + Memory.Length
|
||||
};
|
||||
|
||||
Next = nextSegment;
|
||||
|
||||
return nextSegment;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue