public final class FixedSizePool extends AbstractPool
Pool that caches Poolable objects for reuse.
Please note that this pool offers no resource limiting whatsoever.| Modifier and Type | Field and Description |
|---|---|
private java.util.List |
m_buffer |
private boolean |
m_disposed |
private long |
m_stepTime |
private long |
m_timeout |
| Constructor and Description |
|---|
FixedSizePool(ObjectFactory factory,
int size)
Create a fixed size pool using the object factory and size
supplied.
|
FixedSizePool(ObjectFactory factory,
int size,
long timeout)
Create a fixed size pool using the object factory, size, and
timeout supplied.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Dispose this pool and remove all elements.
|
protected java.lang.Object |
doAcquire()
Perform the actual work of acquiring the object from the pool.
|
protected boolean |
doRelease(java.lang.Object object)
Perform the actual logic to release the pooled object back to the
pool.
|
long |
getTimeout()
Get the timeout in milliseconds for this pool.
|
private java.lang.Object |
popLast() |
java.lang.String |
toString() |
acquire, addPoolListener, disposeInstance, fireAquiredEvent, fireCreatedEvent, fireCreationFailedEvent, fireDisposedEvent, fireDisposeFailedEvent, fireReleasedEvent, getPoolListeners, newInstance, release, removePoolListenerprivate boolean m_disposed
private final java.util.List m_buffer
private final long m_timeout
private final long m_stepTime
public FixedSizePool(ObjectFactory factory, int size) throws java.lang.Exception
factory - the factory to use for the poolsize - the number of items in the pool (hard limit)java.lang.Exception - if there is a problem creating any of the items
in the poolpublic FixedSizePool(ObjectFactory factory, int size, long timeout) throws java.lang.Exception
factory - the factory to use for the poolsize - the number of items in the pool (hard limit)timeout - the timeout in milliseconds to use.java.lang.Exception - if there is a problem creating any of the items
in the poolprotected java.lang.Object doAcquire()
throws java.lang.Exception
AbstractPooldoAcquire in class AbstractPooljava.lang.Exception - if there was a problem acquiring the objectprivate java.lang.Object popLast()
protected boolean doRelease(java.lang.Object object)
AbstractPooldoRelease in class AbstractPoolobject - the object to releasetrue if we also need to dispose of the
objectpublic void dispose()
public java.lang.String toString()
toString in class java.lang.Objectpublic long getTimeout()