Class DirectCleaner

  • All Implemented Interfaces:
    Cleaner

    final class DirectCleaner
    extends java.lang.Object
    implements Cleaner
    • Constructor Detail

      • DirectCleaner

        DirectCleaner()
    • Method Detail

      • 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​(java.nio.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.