public void Advance(int count) { GrpcPreconditions.CheckArgument(count >= 0); GrpcPreconditions.CheckArgument(tailSpacePtr != IntPtr.Zero || count == 0); GrpcPreconditions.CheckArgument(tailSpaceLen >= count); tailSpaceLen = tailSpaceLen - count; tailSpacePtr += count; memoryManagerLazy?.Reset(); }
// provides access to the "tail space" of this buffer. // Use GetSpan when possible for better efficiency. public Memory<byte> GetMemory(int sizeHint = 0) { EnsureBufferSpace(sizeHint); if (memoryManagerLazy == null) { memoryManagerLazy = new SliceMemoryManager(); } memoryManagerLazy.Reset(new Slice(tailSpacePtr, tailSpaceLen)); return memoryManagerLazy.Memory; }
public void Reset(Slice slice, long runningIndex) { pointerMemoryManager.Reset(slice); Memory = pointerMemoryManager.Memory; // maybe not always necessary RunningIndex = runningIndex; }