Top Description Constructors Methods
io.netty5.buffer

public final Class BufferRef

extends BufferHolder<BufferRef>
Class Inheritance
Imports
io.netty5.util.Send, java.lang.invoke.VarHandle

A mutable reference to a buffer.

Constructor Summary

AccessConstructor and Description
private
BufferRef(Buffer
The buffer to reference.
buf
)

Create a reference to the given buffer.

public
BufferRef(Send<Buffer>
The sent buffer to take ownership of.
send
)

Create a reference that holds the exclusive ownership of the sent buffer.

Method Summary

Modifier and TypeMethod and Description
public Buffer

Returns:

The buffer held by the reference.
content
()

Access the buffer in this reference.

protected BufferRef
receive(Buffer
The Buffer that is received by the recipient, and needs to be wrapped in a new BufferHolder instance.
buf
)

Implements abstract io.netty5.buffer.BufferHolder.receive.

Called when a sent BufferHolder is received by the recipient.
public void
replace(Send<Buffer>
The Send with the new Buffer instance that is replacing the currently held buffer.
send
)

Replace the underlying referenced buffer with the given buffer.

Inherited from io.netty5.buffer.BufferHolder:
closeequalsgetBuffergetBufferVolatilehashCodeisAccessiblereplaceBufferreplaceBufferVolatilesendtouch

Constructor Detail

BufferRefback to summary
private BufferRef(Buffer buf)

Create a reference to the given buffer.

Parameters
buf:Buffer

The buffer to reference.

BufferRefback to summary
public BufferRef(Send<Buffer> send)

Create a reference that holds the exclusive ownership of the sent buffer.

Parameters
send:Send<Buffer>

The sent buffer to take ownership of.

Method Detail

contentback to summary
public Buffer content()

Access the buffer in this reference.

Returns:Buffer

The buffer held by the reference.

receiveback to summary
protected BufferRef receive(Buffer buf)

Implements abstract io.netty5.buffer.BufferHolder.receive.

Doc from io.netty5.buffer.BufferHolder.receive.

Called when a sent BufferHolder is received by the recipient. The BufferHolder should return a new concrete instance, that wraps the given Buffer object.

Parameters
buf:Buffer

The Buffer that is received by the recipient, and needs to be wrapped in a new BufferHolder instance.

Returns:BufferRef

A new buffer holder instance, containing the given buffer.

Annotations
@Override
replaceback to summary
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.

Parameters
send:Send<Buffer>

The Send with the new Buffer instance that is replacing the currently held buffer.