public final class VariableSizePool extends AbstractPool implements ManagablePool
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.LinkedList |
m_buffer |
private boolean |
m_disposed |
| Constructor and Description |
|---|
VariableSizePool(ObjectFactory factory,
int size)
Create a VariableSizePool with the supplied factory and initial
size.
|
| Modifier and Type | Method and Description |
|---|---|
void |
dispose()
Dispose of this pool so that it is empty an no longer used.
|
protected java.lang.Object |
doAcquire()
Perform the actual work of acquiring the object from the pool.
|
protected boolean |
doRelease(java.lang.Object pooledObject)
Perform the actual logic to release the pooled object back to the
pool.
|
void |
grow(int byNum)
Grow by the specified amount.
|
private java.lang.Object |
popLast() |
void |
shrink(int byNum)
Shrink the pool by the specified amount.
|
int |
size()
Determine the pool's current size.
|
java.lang.String |
toString() |
acquire, addPoolListener, disposeInstance, fireAquiredEvent, fireCreatedEvent, fireCreationFailedEvent, fireDisposedEvent, fireDisposeFailedEvent, fireReleasedEvent, getPoolListeners, newInstance, release, removePoolListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitacquire, addPoolListener, release, removePoolListenerprivate boolean m_disposed
private final java.util.LinkedList m_buffer
public VariableSizePool(ObjectFactory factory, int size) throws java.lang.Exception
factory - the factory to use to create objectssize - the initial number of elements to createjava.lang.Exception - if there is a problem creating the pooled
objectsprotected 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 pooledObject)
AbstractPooldoRelease in class AbstractPoolpooledObject - the object to releasetrue if we also need to dispose of the
objectpublic void dispose()
public void shrink(int byNum)
ManagablePoolshrink in interface ManagablePoolbyNum - an integer amount to decrease the pool size by.public void grow(int byNum)
ManagablePoolgrow in interface ManagablePoolbyNum - an integer amount to increase the pool size by.public int size()
ManagablePoolsize in interface ManagablePoolpublic java.lang.String toString()
toString in class java.lang.Object