Package io.netty.util.internal
Class DirectCleaner
- java.lang.Object
-
- io.netty.util.internal.DirectCleaner
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classDirectCleaner.CleanableDirectBufferImpl
-
Constructor Summary
Constructors Constructor Description DirectCleaner()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CleanableDirectBufferallocate(int capacity)Create a directByteBufferand return it alongside its cleaning mechanism, in aCleanableDirectBuffer.voidfreeDirectBuffer(java.nio.ByteBuffer buffer)Free a directByteBufferif possiblebooleanhasExpensiveClean()Check if the clean operation is "relatively expensive".CleanableDirectBufferreallocate(CleanableDirectBuffer old, int newCapacity)Reallocate a direct buffer with a new capacity.
-
-
-
Method Detail
-
allocate
public CleanableDirectBuffer allocate(int capacity)
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.
-
reallocate
public CleanableDirectBuffer reallocate(CleanableDirectBuffer old, int newCapacity)
Description copied from interface:CleanerReallocate a direct buffer with a new capacity. The old buffer is consumed and must not be used after this call.The default implementation allocates a new buffer, copies the data, and frees the old one. Implementations may override this to provide more efficient reallocation (e.g. via
Unsafe.reallocateMemory).- Specified by:
reallocatein interfaceCleaner
-
freeDirectBuffer
public void freeDirectBuffer(java.nio.ByteBuffer buffer)
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.
-
-