Class DirectCleaner

java.lang.Object
io.netty.util.internal.DirectCleaner
All Implemented Interfaces:
Cleaner

final class DirectCleaner extends Object implements Cleaner
  • Constructor Details

    • DirectCleaner

      DirectCleaner()
  • Method Details

    • allocate

      public CleanableDirectBuffer allocate(int capacity)
      Description copied from interface: Cleaner
      Create a direct ByteBuffer and return it alongside its cleaning mechanism, in a CleanableDirectBuffer.
      Specified by:
      allocate in interface Cleaner
      Parameters:
      capacity - The desired capacity of the direct buffer.
      Returns:
      The new CleanableDirectBuffer instance.
    • reallocate

      public CleanableDirectBuffer reallocate(CleanableDirectBuffer old, int newCapacity)
      Description copied from interface: Cleaner
      Reallocate 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:
      reallocate in interface Cleaner
    • freeDirectBuffer

      public void freeDirectBuffer(ByteBuffer buffer)
      Description copied from interface: Cleaner
      Free a direct ByteBuffer if possible
      Specified by:
      freeDirectBuffer in interface Cleaner
    • hasExpensiveClean

      public boolean hasExpensiveClean()
      Description copied from interface: Cleaner
      Check if the clean operation is "relatively expensive". Expensive clean operations are fine for pooling allocators, but should be avoided for unpooled buffers.
      Specified by:
      hasExpensiveClean in interface Cleaner
      Returns:
      true if this Cleaner has an expensive clean (i.e. CleanableDirectBuffer.clean()) operation.