@Deprecated public abstract class SimplePool<T> extends Object
Modifier and Type | Field and Description |
---|---|
protected List<T> |
_avail
Deprecated.
|
protected String |
_name
Deprecated.
|
protected Set<T> |
_out
Deprecated.
|
protected int |
_size
Deprecated.
|
Constructor and Description |
---|
SimplePool(String name,
int size)
Deprecated.
Initializes a new pool of objects.
|
Modifier and Type | Method and Description |
---|---|
void |
cleanup(T t)
Deprecated.
override this if you need to do any cleanup
|
protected void |
close()
Deprecated.
Clears the pool of all objects.
|
protected abstract T |
createNew()
Deprecated.
Creates a new object of this pool's type.
|
void |
done(T t)
Deprecated.
call done when you are done with an object form the pool
if there is room and the object is ok will get added
|
T |
get()
Deprecated.
Gets an object from the pool - will block if none are available
|
T |
get(long waitTime)
Deprecated.
Gets an object from the pool - will block if none are available
|
int |
getAvailable()
Deprecated.
|
int |
getInUse()
Deprecated.
|
int |
getMaxSize()
Deprecated.
|
String |
getName()
Deprecated.
|
int |
getTotal()
Deprecated.
|
protected int |
pick(int recommended,
boolean couldCreate)
Deprecated.
Pick a member of
_avail . |
void |
remove(T t)
Deprecated.
|
String |
toString()
Deprecated.
|
protected final String _name
protected final int _size
public SimplePool(String name, int size)
name
- name for the poolsize
- max to hold to at any given time. if < 0 then no limitprotected abstract T createNew()
public void cleanup(T t)
protected int pick(int recommended, boolean couldCreate)
_avail
. This method is called with a lock held on _avail
, so it may be used safely.recommended
- the recommended member to choose.couldCreate
- true if there is room in the pool to create a new objectpublic void done(T t)
t
- Object to addpublic void remove(T t)
public T get() throws InterruptedException
InterruptedException
public T get(long waitTime) throws InterruptedException
waitTime
- negative - forever
0 - return immediately no matter what
positive ms to waitInterruptedException
protected void close()
public String getName()
public int getTotal()
public int getInUse()
public int getAvailable()
public int getMaxSize()