Class Pool<T>

  • Type Parameters:
    T -
    Direct Known Subclasses:
    MpscPool

    public abstract class Pool<T>
    extends java.lang.Object
    A simple encapsulation to provide a pool of objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      Pool​(int maxSize, java.util.function.Consumer<T> cleaner, java.util.function.Supplier<T> supplier)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T borrow()
      Use this to instantiate or return objects from the pool
      void release​(T object)
      Return objects to the pool, they will be either reused or ignored by the max size
      • Methods inherited from class java.lang.Object

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

      • Pool

        public Pool​(int maxSize,
                    java.util.function.Consumer<T> cleaner,
                    java.util.function.Supplier<T> supplier)
    • Method Detail

      • borrow

        public final T borrow()
        Use this to instantiate or return objects from the pool
      • release

        public final void release​(T object)
        Return objects to the pool, they will be either reused or ignored by the max size