public class ConcurrentPool<T>
extends java.lang.Object
This class should not be considered a part of the public API.
Modifier and Type | Class and Description |
---|---|
static interface |
ConcurrentPool.ItemFactory<T>
Factory for creating and closing pooled items.
|
static class |
ConcurrentPool.Prune |
Constructor and Description |
---|
ConcurrentPool(int maxSize,
ConcurrentPool.ItemFactory<T> itemFactory)
Initializes a new pool of objects.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Clears the pool of all objects.
|
void |
ensureMinSize(int minSize,
boolean initialize) |
T |
get()
Gets an object from the pool.
|
T |
get(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Gets an object from the pool - will block if none are available
|
int |
getAvailableCount() |
int |
getCount() |
int |
getInUseCount() |
int |
getMaxSize() |
void |
prune() |
void |
release(T t)
Return an instance of T to the pool.
|
void |
release(T t,
boolean prune)
call done when you are done with an object from the pool if there is room and the object is ok will get added
|
java.lang.String |
toString() |
public ConcurrentPool(int maxSize, ConcurrentPool.ItemFactory<T> itemFactory)
maxSize
- max to hold to at any given time. if < 0 then no limititemFactory
- factory used to create and close items in the poolpublic void release(T t)
release(t, false)
t
- item to return to the poolpublic void release(T t, boolean prune)
t
- item to return to the poolprune
- true if the item should be closed, false if it should be put back in the poolpublic T get()
public T get(long timeout, java.util.concurrent.TimeUnit timeUnit)
timeout
- negative - forever 0 - return immediately no matter what positive ms to waittimeUnit
- the time unit of the timeoutMongoTimeoutException
- if the timeout has been exceededpublic void prune()
public void ensureMinSize(int minSize, boolean initialize)
public void close()
public int getMaxSize()
public int getInUseCount()
public int getAvailableCount()
public int getCount()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2010 - 2020 Adobe. All Rights Reserved