| java.lang.Object org.objectweb.celtix.common.util.AbstractTwoStageCache
AbstractTwoStageCache | abstract public class AbstractTwoStageCache (Code) | | This class pools objects, for efficiency accross a lightweight
fixed-size primary cache and a variable-size secondary cache - the
latter uses soft references to allow the polled object be GCed if
necessary.
To use the cache, a subclass is defined which provides an implementation
of the abstract get() method - this may be conveniently achieved via
an anonymous subclass. The cache is then populated by calling the
populate_cache() method - the reason a two-stage process is used is
to avoid problems with the inner class create() method accessing outer
class data members from the inner class ctor (before its reference to
the outer class is initialized).
author: Eoghan Glynn |
AbstractTwoStageCache | public AbstractTwoStageCache(int pCacheSize, int highWaterMark, int prealloc)(Code) | | Constructor.
Parameters: pCacheSize - primary cache size Parameters: secondary_cache_max - secondary cache high water mark Parameters: preallocation - the number of object to preallocation when thecache is created |
AbstractTwoStageCache | public AbstractTwoStageCache(int pCacheSize, int highWaterMark, int prealloc, Object mutexParam)(Code) | | Constructor.
Parameters: pCacheSize - primary cache size Parameters: secondary_cache_max - secondary cache high water mark Parameters: preallocation - the number of object to preallocation when thecache is created Parameters: mutex - object to use as a monitor |
create | abstract protected E create() throws Exception(Code) | | Over-ride this method to create objects to populate the pool
newly created object |
get | public E get() throws Exception(Code) | | Return a cached or newly created object
an object |
poll | public E poll()(Code) | | Return a cached object if one is available
an object |
populateCache | public void populateCache() throws Exception(Code) | | Populate the cache
|
recycle | public boolean recycle(E oldObject)(Code) | | Recycle an old Object.
Parameters: oldObject - the object to recycle true iff the object can be accomodated in the cache |
|
|