|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mongodb.util.SimplePool<T>
public abstract class SimplePool<T>
This class is NOT part of the public API. Be prepared for non-binary compatible changes in minor releases.
Field Summary | |
---|---|
protected List<T> |
_avail
|
protected String |
_name
|
protected Set<T> |
_out
|
protected int |
_size
|
Constructor Summary | |
---|---|
SimplePool(String name,
int size)
Initializes a new pool of objects. |
Method Summary | |
---|---|
void |
cleanup(T t)
override this if you need to do any cleanup |
protected void |
close()
Clears the pool of all objects. |
protected abstract T |
createNew()
Creates a new object of this pool's type. |
void |
done(T t)
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()
Gets an object from the pool - will block if none are available |
T |
get(long waitTime)
Gets an object from the pool - will block if none are available |
int |
getAvailable()
|
int |
getInUse()
|
int |
getMaxSize()
|
String |
getName()
|
int |
getTotal()
|
protected int |
pick(int recommended,
boolean couldCreate)
Pick a member of _avail . |
void |
remove(T t)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final String _name
protected final int _size
protected final List<T> _avail
protected final Set<T> _out
Constructor Detail |
---|
public SimplePool(String name, int size)
name
- name for the poolsize
- max to hold to at any given time. if < 0 then no limitMethod Detail |
---|
protected 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 object
public 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 wait
InterruptedException
protected void close()
public String getName()
public int getTotal()
public int getInUse()
public int getAvailable()
public int getMaxSize()
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |