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 Link icon

    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 Link icon

    • getItem Link icon

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

      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 Link icon

      void removeAllIdleItems()
      Remove all idle items from the pool.
    • getPoolSize Link icon

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

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

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

      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 Link icon

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