Class ByteBuffersDataOutput.ByteBufferRecycler

  • Enclosing class:
    ByteBuffersDataOutput

    public static final class ByteBuffersDataOutput.ByteBufferRecycler
    extends java.lang.Object
    An implementation of a ByteBuffer allocation and recycling policy. The blocks are recycled if exactly the same size is requested, otherwise they're released to be GCed.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.function.IntFunction<java.nio.ByteBuffer> delegate  
      private java.util.ArrayDeque<java.nio.ByteBuffer> reuse  
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteBufferRecycler​(java.util.function.IntFunction<java.nio.ByteBuffer> delegate)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.nio.ByteBuffer allocate​(int size)  
      void reuse​(java.nio.ByteBuffer buffer)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reuse

        private final java.util.ArrayDeque<java.nio.ByteBuffer> reuse
      • delegate

        private final java.util.function.IntFunction<java.nio.ByteBuffer> delegate
    • Constructor Detail

      • ByteBufferRecycler

        public ByteBufferRecycler​(java.util.function.IntFunction<java.nio.ByteBuffer> delegate)
    • Method Detail

      • allocate

        public java.nio.ByteBuffer allocate​(int size)
      • reuse

        public void reuse​(java.nio.ByteBuffer buffer)