UnboundedPoolpublic class UnboundedPool extends ArrayListPool An UnboundedPool can be used to create a pool of unlimited size. All getObject(....) methods
are guaranteed to return an object irrespective of the wait flag and wait time. Note that
if the objects held in the pool consume a siginificant memory, then maintaining a large
UnboundedPool may cause java.lang.OutOfMemory error (which probably would not have occured
if there was no pooling!!). If memory is an issue then use SoftUnboundedPool.
The initial size of the pool and the load factor of the pool determine how the
pool size adjusts dynamically. For example, if the initial pool size is 100 and if the load factor
is 90, then as soon as 90% of the pool objects are used (given out), then the pool size grows
by 10. |
Fields Summary |
---|
private int | initialSize |
Constructors Summary |
---|
public UnboundedPool(ObjectFactory factory, int initialSize)Create an Unbounded pool.
super(factory, initialSize);
this.initialSize = initialSize;
super.preload(initialSize);
|
Methods Summary |
---|
protected boolean | canCreate()Since this method would be called only if the pool is empty,
and since this an unbounded pool, CREATE IT!!
return true;
| protected java.lang.Object | checkin(java.lang.Object object)Notification when an object is put back into the pool (checkin).
if (waitCount == 0) {
int diff = arrayList.size() - initialSize;
if (diff > initialSize) {
super.destroyPoolObjects(diff);
}
}
arrayList.add(object);
return this;
|
|