Package io.netty.util.internal
Interface CleanableDirectBuffer
-
public interface CleanableDirectBuffer
Encapsulates a directByteBuffer
and its mechanism for immediate deallocation, if any.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.nio.ByteBuffer
buffer()
Get the buffer instance.void
clean()
Deallocate the buffer.default boolean
hasMemoryAddress()
default long
memoryAddress()
Get the native memory address, but only ifhasMemoryAddress()
returns true, otherwise this may return an unspecified value or throw an exception.
-
-
-
Method Detail
-
buffer
java.nio.ByteBuffer buffer()
Get the buffer instance.Note: the buffer must not be accessed after the
clean()
method has been called.- Returns:
- The
ByteBuffer
instance.
-
clean
void clean()
Deallocate the buffer. This method can only be called once per instance, and all usages of the buffer must have ceased before this method is called, and the buffer must not be accessed again after this method has been called.
-
hasMemoryAddress
default boolean hasMemoryAddress()
- Returns:
true
if the native memory address is available, otherwisefalse
.
-
memoryAddress
default long memoryAddress()
Get the native memory address, but only ifhasMemoryAddress()
returns true, otherwise this may return an unspecified value or throw an exception.- Returns:
- The native memory address of this buffer, if available.
-
-