T
- the pool store typepublic abstract class AbstractPool<T> extends java.lang.Object implements Pool<T>
This contains all the logic of a pool except for the actual creation of accessor instances.
Modifier and Type | Field and Description |
---|---|
private SizeOfEngine |
defaultSizeOfEngine |
private PoolEvictor<T> |
evictor |
private long |
maximumPoolSize |
private java.util.List<PoolAccessor<? extends T>> |
poolAccessors |
Constructor and Description |
---|
AbstractPool(long maximumPoolSize,
PoolEvictor<T> evictor,
SizeOfEngine defaultSizeOfEngine)
Create an AbstractPool instance
|
Modifier and Type | Method and Description |
---|---|
PoolAccessor<T> |
createPoolAccessor(T store,
int maxDepth,
boolean abortWhenMaxDepthExceeded)
Return a PoolAccessor whose consumption is tracked by this pool, using a default SizeOf engine.
|
PoolEvictor<T> |
getEvictor()
Return the pool evictor used by this pool.
|
long |
getMaxSize()
Return the maximum size of the pool.
|
java.util.Collection<T> |
getPoolableStores()
Return the stores accessing this pool.
|
long |
getSize()
Return the used size of the pool.
|
void |
registerPoolAccessor(PoolAccessor<? extends T> accessor)
Register an accessor implementation with this pool.
|
void |
removePoolAccessor(PoolAccessor accessor)
Remove the supplied accessor from this pool.
|
void |
setMaxSize(long newSize)
Change the maximum size of the pool.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createPoolAccessor
private volatile long maximumPoolSize
private final PoolEvictor<T> evictor
private final java.util.List<PoolAccessor<? extends T>> poolAccessors
private final SizeOfEngine defaultSizeOfEngine
public AbstractPool(long maximumPoolSize, PoolEvictor<T> evictor, SizeOfEngine defaultSizeOfEngine)
maximumPoolSize
- the maximum size of the pool, in bytes.evictor
- the pool evictor, for cross-store eviction.defaultSizeOfEngine
- the default SizeOf engine used by the accessors.public long getSize()
public long getMaxSize()
getMaxSize
in interface Pool<T>
public void setMaxSize(long newSize)
setMaxSize
in interface Pool<T>
newSize
- the new pool size.public PoolAccessor<T> createPoolAccessor(T store, int maxDepth, boolean abortWhenMaxDepthExceeded)
createPoolAccessor
in interface Pool<T>
store
- the store which will use the created accessor.maxDepth
- maximum depth of the object graph to traverseabortWhenMaxDepthExceeded
- true if the object traversal should be aborted when the max depth is exceededpublic void registerPoolAccessor(PoolAccessor<? extends T> accessor)
registerPoolAccessor
in interface Pool<T>
accessor
- accessor to be registeredpublic void removePoolAccessor(PoolAccessor accessor)
removePoolAccessor
in interface Pool<T>
accessor
- accessor to be removedpublic java.util.Collection<T> getPoolableStores()
getPoolableStores
in interface Pool<T>
public PoolEvictor<T> getEvictor()
getEvictor
in interface Pool<T>