public override void ReleaseReaded() { IntPtr prev = MemorySegment.GetPrev(_memSegPtr); // Отвязываем от текущего. MemorySegment.SetPrev(_memSegPtr, IntPtr.Zero); while (prev != IntPtr.Zero) { IntPtr toRelease = prev; prev = MemorySegment.GetPrev(prev); MemorySegment.SetPrev(toRelease, IntPtr.Zero); MemorySegment.SetNext(toRelease, IntPtr.Zero); MemorySegment.ClearBeforeRelease(toRelease); _byteBufProvider.Release(toRelease); } }
public override void Release() { ReleaseReaded(); IntPtr next = _memSegPtr; while (next != IntPtr.Zero) { IntPtr toRelease = next; next = MemorySegment.GetNext(next); MemorySegment.SetPrev(toRelease, IntPtr.Zero); MemorySegment.SetNext(toRelease, IntPtr.Zero); MemorySegment.ClearBeforeRelease(toRelease); _byteBufProvider.Release(toRelease); } _byteBufProvider.Release(this); _released = true; }