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 voidclose()Close the pool; returned items will be destroyed.intgetActiveCount()Returns the number of allocated items that are currently checked out of the pool.intgetAllocatedCount()Returns the current count of allocated items (in use and idle).intgetIdleCount()Returns the number of items that have been allocated but are not currently in use.TgetItem()Obtains an item from the pool.intgetPoolSize()Returns the current size (limit) of the pool.voidreleaseItem(T t)Releases an item back into the pool.voidremoveAllIdleItems()Removes all idle items from the pool.
-
Method Details
-
getItem
T getItem()Obtains an item from the pool.- Returns:
- the item.
-
releaseItem
Releases an item back into the pool. This must be an item that was previously retrieved usinggetItem().- 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
-