本文介绍了netty中的ChannelBuffer.copy()和ChannelBuffer.duplicate()有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ChannelBuffer.copy()和ChannelBuffer.duplicate()有什么区别?

What's the difference between ChannelBuffer.copy() and ChannelBuffer.duplicate()?

netty中的多个处理程序中,我最终遇到了一个问题,如果我解决了这个问题传递了ChannelBuffer的副本,或者如果我在其上调用了副本,但是我不确定应该使用哪个副本,并且javadoc无法帮助我知道应该使用哪个副本.

In Multiple handlers in netty I ended up coming across a problem that was fixed if I passed a copy of a ChannelBuffer or if I called duplicate on it, but I'm not sure which one should be used, and the javadoc doesn't help to know which one I should be using.

推荐答案

copy()创建一个全新的缓冲区(逐字节).

copy() creates an entirely new buffer (byte-for-byte).

duplicate()创建一个共享原始缓冲区数据但具有自己索引的缓冲区.

duplicate() creates a buffer which shares the original buffer's data, but with its own indexes.

这篇关于netty中的ChannelBuffer.copy()和ChannelBuffer.duplicate()有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 20:54