Netty学习之旅----ByteBuf源码解读之初探UnpooledHeapByteBuf、UnpooledDirectByteBuf
来源:互联网
前沿:
在读源码的过程中我发现有如下几个点,感觉有问题:
1)UnpooledDirectByteBuf的 capacity(int newCapacity)方法,在readerIndex大于或等于newCapacity时,此时不需要将原ByteBuffer中的数据写入到新的ByteBuffer中,这可以理解,但为什么要调用setIndex(newCapacity,newCapacity)将readerIndex,writerIndex设置为capacity呢?设置之后,该ByteBuf不能读也不能写。1)UnpooledDirectB