internal static InstrumentedArrayPooledHeapByteBuffer Create(ArrayPooledByteBufferAllocator allocator, int initialCapacity, int maxCapacity) { var buf = s_recycler.Take(); buf.Reuse(allocator, ArrayPooled.DefaultArrayPool, initialCapacity, maxCapacity); return(buf); }
internal static ArrayPooledHeapByteBuffer NewInstance(ArrayPooledByteBufferAllocator allocator, ArrayPool <byte> arrayPool, byte[] buffer, int length, int maxCapacity) { var buf = Recycler.Take(); buf.Reuse(allocator, arrayPool, buffer, length, maxCapacity); return(buf); }
internal void Reuse(ArrayPooledByteBufferAllocator allocator, ArrayPool <byte> arrayPool, byte[] buffer, int length, int maxCapacity) { _allocator = allocator; _arrayPool = arrayPool; SetArray(buffer); SetMaxCapacity(maxCapacity); SetReferenceCount(1); SetIndex0(0, length); DiscardMarks(); }
/// <summary>Method must be called before reuse this {@link ArrayPooledByteBufAllocator}.</summary> /// <param name="allocator"></param> /// <param name="initialCapacity"></param> /// <param name="maxCapacity"></param> /// <param name="arrayPool"></param> internal void Reuse(ArrayPooledByteBufferAllocator allocator, ArrayPool <byte> arrayPool, int initialCapacity, int maxCapacity) { _allocator = allocator; _arrayPool = arrayPool; SetArray(AllocateArray(initialCapacity)); SetMaxCapacity(maxCapacity); SetReferenceCount(1); SetIndex0(0, 0); DiscardMarks(); }