|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.d_haven.mpool.AbstractPool
org.d_haven.mpool.VariableSizePool
public final class VariableSizePool
This is an Pool
that caches Poolable objects for reuse.
Please note that this pool offers no resource limiting whatsoever.
Field Summary | |
---|---|
private java.util.LinkedList |
m_buffer
|
private boolean |
m_disposed
|
Constructor Summary | |
---|---|
VariableSizePool(ObjectFactory factory,
int size)
Create a VariableSizePool with the supplied factory and initial size. |
Method Summary | |
---|---|
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()
|
Methods inherited from class org.d_haven.mpool.AbstractPool |
---|
acquire, addPoolListener, disposeInstance, fireAquiredEvent, fireCreatedEvent, fireCreationFailedEvent, fireDisposedEvent, fireDisposeFailedEvent, fireReleasedEvent, getPoolListeners, newInstance, release, removePoolListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.d_haven.mpool.Pool |
---|
acquire, addPoolListener, release, removePoolListener |
Field Detail |
---|
private boolean m_disposed
private final java.util.LinkedList m_buffer
Constructor Detail |
---|
public VariableSizePool(ObjectFactory factory, int size) throws java.lang.Exception
factory
- the factory to use to create objectssize
- the initial number of elements to create
java.lang.Exception
- if there is a problem creating the pooled
objectsMethod Detail |
---|
protected java.lang.Object doAcquire() throws java.lang.Exception
AbstractPool
doAcquire
in class AbstractPool
java.lang.Exception
- if there was a problem acquiring the objectprivate java.lang.Object popLast()
protected boolean doRelease(java.lang.Object pooledObject)
AbstractPool
doRelease
in class AbstractPool
pooledObject
- the object to release
true
if we also need to dispose of the
objectpublic void dispose()
public void shrink(int byNum)
ManagablePool
shrink
in interface ManagablePool
byNum
- an integer amount to decrease the pool size by.public void grow(int byNum)
ManagablePool
grow
in interface ManagablePool
byNum
- an integer amount to increase the pool size by.public int size()
ManagablePool
size
in interface ManagablePool
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |