本文整理了Java中io.netty.buffer.ByteBuf.retainedDuplicate()
方法的一些代码示例,展示了ByteBuf.retainedDuplicate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.retainedDuplicate()
方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:retainedDuplicate
[英]Returns a retained buffer which shares the whole region of this buffer. Modifying the content of the returned buffer or this buffer affects each other's content while they maintain separate indexes and marks. This method is identical to buf.slice(0, buf.capacity()). This method does not modify readerIndex or writerIndex of this buffer.
Note that this method returns a #retain() buffer unlike #slice(int,int). This method behaves similarly to duplicate().retain() except that this method may return a buffer implementation that produces less garbage.
[中]返回共享此缓冲区整个区域的保留缓冲区。修改返回的缓冲区或此缓冲区的内容会影响彼此的内容,同时它们会维护单独的索引和标记。此方法与buf相同。切片(0,buf.capacity()。此方法不修改此缓冲区的readerIndex或writerIndex。
请注意,此方法返回一个#retain()缓冲区,与#slice(int,int)不同。此方法的行为类似于duplicate()。retain(),但此方法可能返回产生较少垃圾的缓冲区实现。
代码示例来源:origin: netty/netty
@Override
public ByteBuf retainedDuplicate() {
return buf.retainedDuplicate();
}
代码示例来源:origin: redisson/redisson
@Override
public ByteBuf retainedDuplicate() {
return buf.retainedDuplicate();
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns a buffer containing the {@link #CONNECTION_PREFACE}.
*/
public static ByteBuf connectionPrefaceBuf() {
// Return a duplicate so that modifications to the reader index will not affect the original buffer.
return CONNECTION_PREFACE.retainedDuplicate();
}
代码示例来源:origin: netty/netty
/**
* {@inheritDoc}
* <p>
* This method calls {@code replace(content().retainedDuplicate())} by default.
*/
@Override
public ByteBufHolder retainedDuplicate() {
return replace(data.retainedDuplicate());
}
代码示例来源:origin: netty/netty
@Override
public ByteBuf retainedDuplicate() {
return buf.retainedDuplicate().order(order);
}
代码示例来源:origin: neo4j/neo4j
@Override
protected void decode( ChannelHandlerContext channelHandlerContext, ByteBuf in, List<Object> out )
{
if ( readMessageBoundary )
{
// now we have a complete message in the input buffer
// increment ref count of the buffer and create it's duplicate that shares the content
// duplicate will be the output of this decoded and input for the next one
ByteBuf messageBuf = in.retainedDuplicate();
// signal that whole message was read by making input buffer seem like it was fully read/consumed
in.readerIndex( in.readableBytes() );
// pass the full message to the next handler in the pipeline
out.add( messageBuf );
readMessageBoundary = false;
}
}
代码示例来源:origin: redisson/redisson
/**
* {@inheritDoc}
* <p>
* This method calls {@code replace(content().retainedDuplicate())} by default.
*/
@Override
public ByteBufHolder retainedDuplicate() {
return replace(data.retainedDuplicate());
}
代码示例来源:origin: redisson/redisson
@Override
public ByteBuf retainedDuplicate() {
return buf.retainedDuplicate().order(order);
}
代码示例来源:origin: redisson/redisson
@Override
public PemPrivateKey retainedDuplicate() {
return replace(content.retainedDuplicate());
}
代码示例来源:origin: redisson/redisson
@Override
public PemX509Certificate retainedDuplicate() {
return replace(content.retainedDuplicate());
}
代码示例来源:origin: redisson/redisson
@Override
public PemValue retainedDuplicate() {
return replace(content.retainedDuplicate());
}
代码示例来源:origin: apache/pulsar
public void initiate() {
ByteBuf duplicateBuffer = data.retainedDuplicate();
// duplicatedBuffer has refCnt=1 at this point
lastInitTime = System.nanoTime();
ledger.asyncAddEntry(duplicateBuffer, this, ctx);
// Internally, asyncAddEntry() is refCnt neutral to respect to the passed buffer and it will keep a ref on it
// until is done using it. We need to release this buffer here to balance the 1 refCnt added at the creation
// time.
duplicateBuffer.release();
}
代码示例来源:origin: wildfly/wildfly
/**
* {@inheritDoc}
* <p>
* This method calls {@code replace(content().retainedDuplicate())} by default.
*/
@Override
public ByteBufHolder retainedDuplicate() {
return replace(data.retainedDuplicate());
}
代码示例来源:origin: netty/netty
private static Object safeDuplicate(Object message) {
if (message instanceof ByteBuf) {
return ((ByteBuf) message).retainedDuplicate();
} else if (message instanceof ByteBufHolder) {
return ((ByteBufHolder) message).retainedDuplicate();
} else {
return ReferenceCountUtil.retain(message);
}
}
代码示例来源:origin: netty/netty
@Override
public DatagramPacket retainedDuplicate() {
return replace(content().retainedDuplicate());
}
代码示例来源:origin: redisson/redisson
private static Object safeDuplicate(Object message) {
if (message instanceof ByteBuf) {
return ((ByteBuf) message).retainedDuplicate();
} else if (message instanceof ByteBufHolder) {
return ((ByteBufHolder) message).retainedDuplicate();
} else {
return ReferenceCountUtil.retain(message);
}
}
代码示例来源:origin: redisson/redisson
@Override
public DatagramPacket retainedDuplicate() {
return replace(content().retainedDuplicate());
}
代码示例来源:origin: redisson/redisson
@Override
public DnsRawRecord retainedDuplicate() {
return replace(content().retainedDuplicate());
}
代码示例来源:origin: apache/pulsar
public static EntryImpl create(EntryImpl other) {
EntryImpl entry = RECYCLER.get();
entry.ledgerId = other.ledgerId;
entry.entryId = other.entryId;
entry.data = other.data.retainedDuplicate();
entry.setRefCnt(1);
return entry;
}
代码示例来源:origin: wildfly/wildfly
private static Object safeDuplicate(Object message) {
if (message instanceof ByteBuf) {
return ((ByteBuf) message).retainedDuplicate();
} else if (message instanceof ByteBufHolder) {
return ((ByteBufHolder) message).retainedDuplicate();
} else {
return ReferenceCountUtil.retain(message);
}
}
内容来源于网络,如有侵权,请联系作者删除!