|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.primix.tapestry.util.pool.Pool
A Pool is used to pool instances of a useful class. It uses
keys, much like a Map
, to identify a list of pooled objects.
Retrieving an object from the Pool atomically removes it from the
pool. It can then be stored again later.
The implementation of Pool is threadsafe.
Pool implements ICleanable
, with a goal of
only keeping pooled objects that have been needed within
a recent time frame. A generational system is used, where each
pooled object is assigned a generation count. executeCleanup()
culls objects whose generation count is too old (outside of a
window
).
Constructor Summary | |
Pool()
Creates a new Pool using the default map size. |
|
Pool(boolean useSharedJanitor)
|
|
Pool(int mapSize)
Creates a new Pool using the specified map size. |
|
Pool(int mapSize,
boolean useSharedJanitor)
Standard constructor. |
Method Summary | |
void |
clear()
Removes all previously pooled objects from this Pool. |
void |
executeCleanup()
Peforms culling of unneeded pooled objects. |
int |
getKeyCount()
Returns the number of keys within the pool. |
int |
getPooledCount()
Returns the number of object pooled, the sum of the number of objects in pooled under each key. |
int |
getWindow()
Returns the window used to cull pooled objects during a cleanup. |
void |
renderDescription(IResponseWriter writer)
Object should render a description of itself to the writer. |
java.lang.Object |
retrieve(java.lang.Object key)
Returns a previously pooled object with the given key, or null if no such object exists. |
void |
setWindow(int value)
Sets the window, or number of generations that an object may stay in the pool before being culled. |
void |
store(java.lang.Object key,
java.lang.Object object)
Stores an object in the pool for later retrieval. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Pool()
public Pool(int mapSize)
public Pool(boolean useSharedJanitor)
useSharedJanitor
- if true, then the Pool is added to
the shared janitor
.public Pool(int mapSize, boolean useSharedJanitor)
mapSize
- initial size of the map.useSharedJanitor
- if true, then the Pool is added to
the shared janitor
.Method Detail |
public int getWindow()
public void setWindow(int value)
java.lang.IllegalArgumentException
- if value is less than 1.public java.lang.Object retrieve(java.lang.Object key)
store(Object,Object)
.public void store(java.lang.Object key, java.lang.Object object)
IPoolable.resetForPool()
, if the object
implements the IPoolable
interface.public void clear()
public int getPooledCount()
public int getKeyCount()
public void executeCleanup()
executeCleanup
in interface ICleanable
public java.lang.String toString()
toString
in class java.lang.Object
public void renderDescription(IResponseWriter writer)
IRenderDescription
renderDescription
in interface IRenderDescription
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |