Interface Pool<T>

All Known Implementing Classes:
SimplePool

public interface Pool<T>
Represents a pool of items.
Since:
2.2
Author:
Gary Russell
  • Method Summary

    Modifier and Type Method Description
    default void close()
    Close the pool; returned items will be destroyed.
    int getActiveCount()
    Returns the number of allocated items that are currently checked out of the pool.
    int getAllocatedCount()
    Returns the current count of allocated items (in use and idle).
    int getIdleCount()
    Returns the number of items that have been allocated but are not currently in use.
    T getItem()
    Obtains an item from the pool.
    int getPoolSize()
    Returns the current size (limit) of the pool.
    void releaseItem​(T t)
    Releases an item back into the pool.
    void removeAllIdleItems()
    Removes all idle items from the pool.
  • Method Details

    • getItem

      T getItem()
      Obtains an item from the pool.
      Returns:
      the item.
    • releaseItem

      void releaseItem​(T t)
      Releases an item back into the pool. This must be an item that was previously retrieved using getItem().
      Parameters:
      t - the item.
      Throws:
      IllegalArgumentException - when a "foreign" object is released.
    • removeAllIdleItems

      void removeAllIdleItems()
      Removes all idle items from the pool.
    • getPoolSize

      int getPoolSize()
      Returns the current size (limit) of the pool.
      Returns:
      the size.
    • getIdleCount

      int getIdleCount()
      Returns the number of items that have been allocated but are not currently in use.
      Returns:
      The number of items.
    • getActiveCount

      int getActiveCount()
      Returns the number of allocated items that are currently checked out of the pool.
      Returns:
      The number of items.
    • getAllocatedCount

      int getAllocatedCount()
      Returns the current count of allocated items (in use and idle). May be less than the pool size, and reflects the high water mark of pool usage.
      Returns:
      the number of items.
    • close

      default void close()
      Close the pool; returned items will be destroyed.
      Since:
      4.3.23