Package org.apache.druid.collections
Class DefaultBlockingPool<T>
- java.lang.Object
-
- org.apache.druid.collections.DefaultBlockingPool<T>
-
- All Implemented Interfaces:
BlockingPool<T>
public class DefaultBlockingPool<T> extends Object implements BlockingPool<T>
Pool that pre-generates objects up to a limit, then permits possibly-blocking "take" operations.
-
-
Constructor Summary
Constructors Constructor Description DefaultBlockingPool(com.google.common.base.Supplier<T> generator, int limit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getPendingRequests()
Returns the count of the requests waiting to acquire a batch of resources.int
getPoolSize()
int
maxSize()
List<ReferenceCountingResourceHolder<T>>
takeBatch(int elementNum)
Take resources from the pool, waiting if necessary until the elements of the given number become available.List<ReferenceCountingResourceHolder<T>>
takeBatch(int elementNum, long timeoutMs)
Take resources from the pool, waiting up to the specified wait time if necessary for elements of the given number to become available.
-
-
-
Constructor Detail
-
DefaultBlockingPool
public DefaultBlockingPool(com.google.common.base.Supplier<T> generator, int limit)
-
-
Method Detail
-
maxSize
public int maxSize()
- Specified by:
maxSize
in interfaceBlockingPool<T>
-
getPoolSize
public int getPoolSize()
-
takeBatch
public List<ReferenceCountingResourceHolder<T>> takeBatch(int elementNum, long timeoutMs)
Description copied from interface:BlockingPool
Take resources from the pool, waiting up to the specified wait time if necessary for elements of the given number to become available.- Specified by:
takeBatch
in interfaceBlockingPool<T>
- Parameters:
elementNum
- number of resources to taketimeoutMs
- maximum time to wait for resources, in milliseconds.- Returns:
- a list of resource holders. An empty list is returned if
elementNum
resources aren't available.
-
takeBatch
public List<ReferenceCountingResourceHolder<T>> takeBatch(int elementNum)
Description copied from interface:BlockingPool
Take resources from the pool, waiting if necessary until the elements of the given number become available.- Specified by:
takeBatch
in interfaceBlockingPool<T>
- Parameters:
elementNum
- number of resources to take- Returns:
- a list of resource holders. An empty list is returned if
elementNum
resources aren't available.
-
getPendingRequests
public long getPendingRequests()
Description copied from interface:BlockingPool
Returns the count of the requests waiting to acquire a batch of resources.- Specified by:
getPendingRequests
in interfaceBlockingPool<T>
- Returns:
- count of pending requests
-
-