Class ThreadSafeLenientFixedSizePool<T>

java.lang.Object
com.illumon.util.pool.ThreadSafeLenientFixedSizePool<T>
All Implemented Interfaces:
com.fishlib.base.pool.Pool<T>, com.fishlib.base.pool.Pool.MultiGiver<T>, com.fishlib.base.pool.Pool.MultiPool<T>, com.fishlib.base.pool.Pool.MultiTaker<T>, com.fishlib.base.pool.Pool.SinglePool<T>, PoolEx<T>

public class ThreadSafeLenientFixedSizePool<T> extends Object implements com.fishlib.base.pool.Pool.MultiPool<T>, PoolEx<T>
A pool that
  • holds at least size items,
  • creates size items in the pool immediately,
  • creates a new item when the pool underflows,
  • discards the item when the pool overflows,
  • optionally clears the items given to it, and
  • IS thread-safe
Forked from com.fishlib.base.pool.ThreadSafeLenientFixedSizePool January 2021
  • Field Details

  • Constructor Details

    • ThreadSafeLenientFixedSizePool

      public ThreadSafeLenientFixedSizePool(String name, int size, com.fishlib.base.Function.Nullary<T> initFactory, com.fishlib.base.Function.Nullary<T> overflowFactory, com.fishlib.base.Procedure.Unary<? super T> clearingProcedure)
    • ThreadSafeLenientFixedSizePool

      public ThreadSafeLenientFixedSizePool(String name, int size, com.fishlib.base.Function.Unary<T,ThreadSafeLenientFixedSizePool<T>> initFactory, com.fishlib.base.Function.Unary<T,ThreadSafeLenientFixedSizePool<T>> overflowFactory, com.fishlib.base.Procedure.Unary<? super T> clearingProcedure)
  • Method Details

    • take

      public T take()
      Specified by:
      take in interface com.fishlib.base.pool.Pool<T>
    • give

      public void give(T item)
      Specified by:
      give in interface com.fishlib.base.pool.Pool<T>
    • giveInternal

      protected boolean giveInternal(T item)
    • takeMaybeNull

      @Deprecated public T takeMaybeNull()
      Deprecated.
    • tryTake

      public T tryTake()
      Description copied from interface: PoolEx
      Take an item if immediately available, else return null.
      Specified by:
      tryTake in interface PoolEx<T>
      Returns:
      a pool item or null