public abstract class

SimplePool

extends Object
implements DynamicMBean
java.lang.Object
   ↳ com.mongodb.util.SimplePool<T>
Known Direct Subclasses

Summary

Fields
protected final List<T> _availSafe
protected final boolean _debug
protected final int _maxToKeep
protected final int _maxTotal
protected final MBeanInfo _mbeanInfo
protected final String _name
protected final boolean _trackLeaks
Public Constructors
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.
Public Methods
int available()
void cleanup(T t)
override this if you need to do any cleanup
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(long waitTime)
Gets an object from the pool - will block if none are available
T get()
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
void remove(T t)
void setAttribute(Attribute attribute)
AttributeList setAttributes(AttributeList attributes)
String toString()
int total()
Protected Methods
void clear()
Clears the pool of all objects.
abstract T createNew()
Creates a new object of this pool's type.
int pick(int iThink, boolean couldCreate)
[Expand]
Inherited Methods
From class java.lang.Object
From interface javax.management.DynamicMBean

Fields

protected final List<T> _availSafe

protected final boolean _debug

protected final int _maxToKeep

protected final int _maxTotal

protected final MBeanInfo _mbeanInfo

protected final String _name

protected final boolean _trackLeaks

Public Constructors

public SimplePool (String name, int maxToKeep, int maxTotal)

See full constructor docs

public SimplePool (String name, int maxToKeep, int maxTotal, boolean trackLeaks, boolean debug)

Initializes a new pool of objects.

Parameters
name name for the pool
maxToKeep max to hold to at any given time. if < 0 then no limit
maxTotal max to have allocated at any point. if there are no more, get() will block
trackLeaks if leaks should be tracked

Public Methods

public int available ()

public void cleanup (T t)

override this if you need to do any cleanup

public 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

Parameters
t Object to add

public int everCreated ()

public T get (long waitTime)

Gets an object from the pool - will block if none are available

Parameters
waitTime negative - forever 0 - return immediately no matter what positive ms to wait
Returns
  • An object from the pool

public T get ()

Gets an object from the pool - will block if none are available

Returns
  • An object from the pool

public Iterator<T> getAll ()

public Object getAttribute (String attribute)

public AttributeList getAttributes (String[] attributes)

public MBeanInfo getMBeanInfo ()

public int inUse ()

public Object invoke (String actionName, Object[] params, String[] signature)

public int maxToKeep ()

public 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

Returns
  • true if the object is ok to be added back to pool

public void remove (T t)

public void setAttribute (Attribute attribute)

public AttributeList setAttributes (AttributeList attributes)

public String toString ()

public int total ()

Protected Methods

protected void clear ()

Clears the pool of all objects.

protected abstract T createNew ()

Creates a new object of this pool's type.

Returns
  • the new object.

protected int pick (int iThink, boolean couldCreate)

Returns
  • >= 0 the one to use, -1 don't use any