public ByteBuf GetDefault() { int size; IntPtr dataPtr = GetDefaultDataIntPtr(out size); UnmanagedByteBuf byteBuf = (UnmanagedByteBuf)WrapDefault(dataPtr, 0 /* filledSize */); return(byteBuf); }
private UnmanagedByteBuf GetByteBufCore() { ByteBuf byteBuf; if (!_byteBufs.TryDequeue(out byteBuf)) { byteBuf = new UnmanagedByteBuf(this); } return((UnmanagedByteBuf)byteBuf); }
public IUnmanagedByteBuf WrapDefault(IntPtr dataPtr, int filledSize) { IntPtr memSegPtr = MemorySegment.GetMemSegPtrByDataPtr(dataPtr); UnmanagedByteBuf byteBuf = GetByteBufCore(); byteBuf.Attach(memSegPtr); byteBuf.SetWrite(filledSize); return(byteBuf); }
public override void Append(ByteBuf byteBuf) { UnmanagedByteBuf unmanagedByteBuf = (UnmanagedByteBuf)byteBuf; IntPtr appendixCurrentMemSegPtr = unmanagedByteBuf._memSegPtr; IntPtr appendixLastMemSegPtr = unmanagedByteBuf._lastMemSegPtr; MemorySegment.SetNext(_lastMemSegPtr, appendixCurrentMemSegPtr); MemorySegment.SetPrev(appendixCurrentMemSegPtr, _lastMemSegPtr); _lastMemSegPtr = appendixLastMemSegPtr; _globalWrited += unmanagedByteBuf._globalWrited; // Т.к. мы все забрали у присоединяемого буфера, то буфер как обертка больше не нужен. // Освобождаем его. unmanagedByteBuf.ReleaseCore(); }
internal void Release(UnmanagedByteBuf unmanagedByteBuf) { _byteBufs.Enqueue(unmanagedByteBuf); }