zinger.util.recycling
Class CappedObjectRecycler
java.lang.Object
zinger.util.recycling.ObjectRecycler
zinger.util.recycling.CappedObjectRecycler
- All Implemented Interfaces:
- ObjectPool
public class CappedObjectRecycler
- extends ObjectRecycler
Performs the same task as its superclass, but allows the ability to specify the maximum number
of cached instances. Useful when we know the approximate range of usage and don't want too many
objects sitting cached in memory indefinitely after a surge.
Field Summary |
protected int |
cap
|
Method Summary |
boolean |
recycleObject(java.lang.Object obj)
Rejects the object if the instance cache exceeds specified size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cap
protected final int cap
CappedObjectRecycler
public CappedObjectRecycler(ObjectGenerator generator,
java.util.List instances,
int cap)
CappedObjectRecycler
public CappedObjectRecycler(ObjectGenerator generator,
int cap)
recycleObject
public boolean recycleObject(java.lang.Object obj)
- Rejects the object if the instance cache exceeds specified size.
- Specified by:
recycleObject
in interface ObjectPool
- Overrides:
recycleObject
in class ObjectRecycler
- Returns:
- whether the object was recycled
- See Also:
ObjectRecycler.getObject(java.lang.Object)