public override IMemoryOwner <byte> Rent(int size = AnySize) { if (size > _blockSize) { MemoryPoolThrowHelper.ThrowArgumentOutOfRangeException_BufferRequestTooLarge(_blockSize); } var block = Lease(); return(block); }
public override IMemoryOwner <byte> Rent(int size = AnySize) { if (size > _blockSize) { MemoryPoolThrowHelper.ThrowArgumentOutOfRangeException_BufferRequestTooLarge(_blockSize); } if (_isDisposed) { MemoryPoolThrowHelper.ThrowObjectDisposedException(MemoryPoolThrowHelper.ExceptionArgument.MemoryPool); } if (_blocks.TryDequeue(out var block)) { // block successfully taken from the stack - return it return(block); } return(new MemoryPoolBlock(this, BlockSize)); }