Class NettyNioBufferReleasingAllocator

java.lang.Object
eu.cloudnetservice.driver.network.netty.buffer.NettyNioBufferReleasingAllocator
All Implemented Interfaces:
io.netty5.buffer.AllocatorControl, io.netty5.buffer.BufferAllocator, io.netty5.util.SafeCloseable, AutoCloseable

@Internal public final class NettyNioBufferReleasingAllocator extends Object implements io.netty5.buffer.BufferAllocator, io.netty5.buffer.AllocatorControl
A buffer allocator that is allocating nio buffers and frees them directly when they are closed.
Since:
4.0
  • Field Details

    • manager

      private final io.netty5.buffer.bytebuffer.ByteBufferMemoryManager manager
    • closed

      private volatile boolean closed
  • Constructor Details

    • NettyNioBufferReleasingAllocator

      public NettyNioBufferReleasingAllocator()
      Constructs a new buffer allocator instance. All instances are backed by a byte buffer memory manager.
  • Method Details

    • notAbleToFreeBuffers

      public static boolean notAbleToFreeBuffers()
      Get if this allocator can free direct buffers. If this method returns false, this allocator shouldn't be used as it does nothing. Use the default netty allocator instead.
      Returns:
      if this allocator is able to free direct nio buffers.
    • getAllocationType

      @NonNull public @NonNull io.netty5.buffer.AllocationType getAllocationType()
      Specified by:
      getAllocationType in interface io.netty5.buffer.BufferAllocator
    • allocate

      @NonNull public @NonNull io.netty5.buffer.Buffer allocate(int size)
      Specified by:
      allocate in interface io.netty5.buffer.BufferAllocator
    • constBufferSupplier

      @NonNull public @NonNull Supplier<io.netty5.buffer.Buffer> constBufferSupplier(byte[] bytes)
      Specified by:
      constBufferSupplier in interface io.netty5.buffer.BufferAllocator
    • getAllocator

      @NonNull public @NonNull io.netty5.buffer.BufferAllocator getAllocator()
      Specified by:
      getAllocator in interface io.netty5.buffer.AllocatorControl
    • isPooling

      public boolean isPooling()
      Specified by:
      isPooling in interface io.netty5.buffer.BufferAllocator
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface io.netty5.buffer.BufferAllocator
      Specified by:
      close in interface io.netty5.util.SafeCloseable