Package io.netty.util.internal
Class CleanerJava24Linker.CleanableDirectBufferImpl
- java.lang.Object
-
- io.netty.util.internal.CleanerJava24Linker.CleanableDirectBufferImpl
-
- All Implemented Interfaces:
CleanableDirectBuffer
- Enclosing class:
- CleanerJava24Linker
private static final class CleanerJava24Linker.CleanableDirectBufferImpl extends java.lang.Object implements CleanableDirectBuffer
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.ByteBufferbufferprivate longmemoryAddress
-
Constructor Summary
Constructors Constructor Description CleanableDirectBufferImpl(java.nio.ByteBuffer buffer, long memoryAddress)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static CleanableDirectBufferallocate(int capacity)java.nio.ByteBufferbuffer()Get the buffer instance.voidclean()Deallocate the buffer.booleanhasMemoryAddress()longmemoryAddress()Get the native memory address, but only ifCleanableDirectBuffer.hasMemoryAddress()returns true, otherwise this may return an unspecified value or throw an exception.
-
-
-
Method Detail
-
allocate
static CleanableDirectBuffer allocate(int capacity)
-
buffer
public java.nio.ByteBuffer buffer()
Description copied from interface:CleanableDirectBufferGet the buffer instance.Note: the buffer must not be accessed after the
CleanableDirectBuffer.clean()method has been called.- Specified by:
bufferin interfaceCleanableDirectBuffer- Returns:
- The
ByteBufferinstance.
-
clean
public void clean()
Description copied from interface:CleanableDirectBufferDeallocate 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.- Specified by:
cleanin interfaceCleanableDirectBuffer
-
hasMemoryAddress
public boolean hasMemoryAddress()
- Specified by:
hasMemoryAddressin interfaceCleanableDirectBuffer- Returns:
trueif the native memory address is available, otherwisefalse.
-
memoryAddress
public long memoryAddress()
Description copied from interface:CleanableDirectBufferGet the native memory address, but only ifCleanableDirectBuffer.hasMemoryAddress()returns true, otherwise this may return an unspecified value or throw an exception.- Specified by:
memoryAddressin interfaceCleanableDirectBuffer- Returns:
- The native memory address of this buffer, if available.
-
-