- java.lang.Object
-
- io.netty5.buffer.api.BufferHolder<BufferRef>
-
- io.netty5.buffer.api.BufferRef
-
- All Implemented Interfaces:
io.netty5.util.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 Buffer
content()
Access the buffer in this reference.protected BufferRef
receive(Buffer buf)
Called when a sentBufferHolder
is received by the recipient.void
replace(io.netty5.util.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
-
-
-
-
Constructor Detail
-
BufferRef
public BufferRef(io.netty5.util.Send<Buffer> send)
Create a reference that holds the exclusive ownership of the sent buffer.- Parameters:
send
- The sent buffer to take ownership of.
-
-
Method Detail
-
receive
protected BufferRef receive(Buffer buf)
Description copied from class:BufferHolder
Called when a sentBufferHolder
is received by the recipient. TheBufferHolder
should return a new concrete instance, that wraps the givenBuffer
object.- Specified by:
receive
in classBufferHolder<BufferRef>
- Parameters:
buf
- TheBuffer
that is received by the recipient, and needs to be wrapped in a newBufferHolder
instance.- Returns:
- A new buffer holder instance, containing the given buffer.
-
replace
public void replace(io.netty5.util.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.
- Parameters:
send
- TheSend
with the newBuffer
instance that is replacing the currently held buffer.
-
content
public Buffer content()
Access the buffer in this reference.- Returns:
- The buffer held by the reference.
-
-