Package io.netty5.buffer.api
Class BufferRef
- java.lang.Object
-
- io.netty5.buffer.api.BufferHolder<BufferRef>
-
- io.netty5.buffer.api.BufferRef
-
- All Implemented Interfaces:
Resource<BufferRef>,AutoCloseable
public final class BufferRef extends BufferHolder<BufferRef>
A mutable reference to a buffer.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Buffercontent()Access the buffer in this reference.protected BufferRefreceive(Buffer buf)Called when a sentBufferHolderis received by the recipient.voidreplace(Send<Buffer> send)Replace the underlying referenced buffer with the given buffer.-
Methods inherited from class io.netty5.buffer.api.BufferHolder
close, equals, getBuffer, getBufferVolatile, hashCode, isAccessible, replaceBuffer, replaceBufferVolatile, send, touch
-
-
-
-
Method Detail
-
receive
protected BufferRef receive(Buffer buf)
Description copied from class:BufferHolderCalled when a sentBufferHolderis received by the recipient. TheBufferHoldershould return a new concrete instance, that wraps the givenBufferobject.- Specified by:
receivein classBufferHolder<BufferRef>- Parameters:
buf- TheBufferthat is received by the recipient, and needs to be wrapped in a newBufferHolderinstance.- Returns:
- A new buffer holder instance, containing the given buffer.
-
replace
public void replace(Send<Buffer> send)
Replace the underlying referenced buffer with the given buffer.Note: this method closes the current buffer, and takes exclusive ownership of the received buffer.
The buffer assignment is performed using a volatile store.
-
content
public Buffer content()
Access the buffer in this reference.- Returns:
- The buffer held by the reference.
-
-