|
||||||||||
| 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>
| Field Summary | |
|---|---|
protected List<T> |
_availSafe
|
protected boolean |
_debug
|
protected int |
_maxToKeep
|
protected int |
_maxTotal
|
protected MBeanInfo |
_mbeanInfo
|
protected String |
_name
|
protected boolean |
_trackLeaks
|
| Constructor Summary | |
|---|---|
SimplePool(String name,
int maxToKeep,
int maxTotal)
See full constructor docs |
|
SimplePool(String name,
int maxToKeep,
int maxTotal,
boolean trackLeaks,
boolean debug)
Initializes a new pool of objects. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
cleanup(T t)
override this if you need to do any cleanup |
protected void |
clear()
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 |
int |
everCreated()
|
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 |
Iterator<T> |
getAll()
|
Object |
getAttribute(String attribute)
|
AttributeList |
getAttributes(String[] attributes)
|
MBeanInfo |
getMBeanInfo()
|
int |
inUse()
|
Object |
invoke(String actionName,
Object[] params,
String[] signature)
|
int |
maxToKeep()
|
boolean |
ok(T t)
callback to determine if an object is ok to be added back to the pool or used will be called when something is put back into the queue and when it comes out |
protected int |
pick(int iThink,
boolean couldCreate)
|
void |
remove(T t)
|
void |
setAttribute(Attribute attribute)
|
AttributeList |
setAttributes(AttributeList attributes)
|
String |
toString()
|
int |
total()
|
| 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 _maxToKeep
protected final int _maxTotal
protected final boolean _trackLeaks
protected final boolean _debug
protected final MBeanInfo _mbeanInfo
protected final List<T> _availSafe
| Constructor Detail |
|---|
public SimplePool(String name,
int maxToKeep,
int maxTotal)
public SimplePool(String name,
int maxToKeep,
int maxTotal,
boolean trackLeaks,
boolean debug)
name - name for the poolmaxToKeep - max to hold to at any given time. if < 0 then no limitmaxTotal - max to have allocated at any point. if there are no more, get() will blocktrackLeaks - if leaks should be tracked| Method Detail |
|---|
protected abstract T createNew()
public boolean ok(T t)
public void cleanup(T t)
protected int pick(int iThink,
boolean couldCreate)
public void done(T t)
t - Object to addpublic void remove(T t)
public T get()
public T get(long waitTime)
waitTime - negative - forever
0 - return immediately no matter what
positive ms to wait
protected void clear()
public int total()
public int inUse()
public Iterator<T> getAll()
public int available()
public int everCreated()
public int maxToKeep()
public Object getAttribute(String attribute)
getAttribute in interface DynamicMBeanpublic AttributeList getAttributes(String[] attributes)
getAttributes in interface DynamicMBeanpublic MBeanInfo getMBeanInfo()
getMBeanInfo in interface DynamicMBean
public Object invoke(String actionName,
Object[] params,
String[] signature)
invoke in interface DynamicMBeanpublic void setAttribute(Attribute attribute)
setAttribute in interface DynamicMBeanpublic AttributeList setAttributes(AttributeList attributes)
setAttributes in interface DynamicMBeanpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||