Class CleanerJava25
java.lang.Object
io.netty.util.internal.CleanerJava25
- All Implemented Interfaces:
Cleaner
Provide a way to clean direct
ByteBuffer instances on Java 24+,
where we don't have Unsafe available, but we have memory segments.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final MethodHandleprivate static final InternalLogger -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallocate(int capacity) Create a directByteBufferand return it alongside its cleaning mechanism, in aCleanableDirectBuffer.voidfreeDirectBuffer(ByteBuffer buffer) Free a directByteBufferif possiblebooleanCheck if the clean operation is "relatively expensive".(package private) static booleanMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Cleaner
reallocate
-
Field Details
-
logger
-
INVOKE_ALLOCATOR
-
-
Constructor Details
-
CleanerJava25
CleanerJava25()
-
-
Method Details
-
isSupported
static boolean isSupported() -
allocate
Description copied from interface:CleanerCreate a directByteBufferand return it alongside its cleaning mechanism, in aCleanableDirectBuffer.- Specified by:
allocatein interfaceCleaner- Parameters:
capacity- The desired capacity of the direct buffer.- Returns:
- The new
CleanableDirectBufferinstance.
-
freeDirectBuffer
Description copied from interface:CleanerFree a directByteBufferif possible- Specified by:
freeDirectBufferin interfaceCleaner
-
hasExpensiveClean
public boolean hasExpensiveClean()Description copied from interface:CleanerCheck if the clean operation is "relatively expensive". Expensive clean operations are fine for pooling allocators, but should be avoided for unpooled buffers.- Specified by:
hasExpensiveCleanin interfaceCleaner- Returns:
trueif this Cleaner has an expensive clean (i.e.CleanableDirectBuffer.clean()) operation.
-