Interface Pool<T>

Type Parameters:
T - pool element type.
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 the pool; returned items will be destroyed.
    int
    Return the number of allocated items that are currently checked out of the pool.
    int
    Return the current count of allocated items (in use and idle).
    int
    Return the number of items that have been allocated but are not currently in use.
    Obtain an item from the pool.
    int
    Return the current size (limit) of the pool.
    void
    Release an item back into the pool.
    void
    Remove all idle items from the pool.
  • Method Details

    • getItem

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

      void releaseItem(T t)
      Release 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()
      Remove all idle items from the pool.
    • getPoolSize

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

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

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

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

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