System.ClientModel.Internal.UnsafeBufferSequence
This class is a helper to write to a IBufferWriter<T> in a thread safe manner.
It uses the shared pool to allocate buffers and returns them to the pool when disposed.
Since there is no way to ensure someone didn't keep a reference to one of the buffers
it must be disposed of in the same context it was created and its referenced should not be stored or shared.
namespace System.ClientModel.Internal
{
internal sealed class UnsafeBufferSequence : IBufferWriter<byte>, IDisposable
{
public UnsafeBufferSequence(int segmentSize = 16384);
public void Advance(int bytesWritten);
public Memory<byte> GetMemory(int sizeHint = 0);
public Span<byte> GetSpan(int sizeHint = 0);
public void Dispose();
public Reader ExtractReader();
}
}