Top Description Fields Constructors Methods
net.sf.ehcache.pool.impl

pack-priv final Class AtomicPoolAccessor

extends AbstractPoolAccessor
Class Inheritance
Imports
java.util.concurrent.atomic.AtomicLong, net.sf.ehcache.pool.Pool, .PoolParticipant, .SizeOfEngine

The PoolAccessor class of the BoundedPool
Authors
Chris Dennis, Ludovic Orban

Field Summary

Modifier and TypeField and Description
private final AtomicLong
Inherited from net.sf.ehcache.pool.impl.AbstractPoolAccessor:
sizeOfEngine

Constructor Summary

AccessConstructor and Description
pack-priv
AtomicPoolAccessor(Pool
pool to be accessed
pool
,
PoolParticipant
accessing poolParticipant
poolParticipant
,
SizeOfEngine
engine used to size objects
sizeOfEngine
,
long
initial size of the poolParticipant
currentSize
)

Creates an atomic pool accessor with the specified properties.

Method Summary

Modifier and TypeMethod and Description
protected long
add(long
number of bytes to add
sizeOf
,
boolean
true if the pool should accept adding the element, even if it's out of resources
force
)

Implements abstract net.sf.ehcache.pool.impl.AbstractPoolAccessor.add.

Add a specific number of bytes to the pool.
protected boolean
canAddWithoutEvicting(long
number of bytes to test against
sizeOf
)

Implements abstract net.sf.ehcache.pool.impl.AbstractPoolAccessor.canAddWithoutEvicting.

Check if there is enough room in the pool to add a specific number of bytes without provoking any eviction
public long
delete(long
number of bytes
sizeOf
)

Implements net.sf.ehcache.pool.PoolAccessor.delete.

Delete a fixed number of bytes from the pool.
protected void
doClear()

Implements abstract net.sf.ehcache.pool.impl.AbstractPoolAccessor.doClear.

Free resources used by this accessor.
public long
getSize()

Implements net.sf.ehcache.pool.PoolAccessor.getSize.

Return how many bytes this accessor consumes from the pool.
Inherited from net.sf.ehcache.pool.impl.AbstractPoolAccessor:
addcanAddWithoutEvictingcheckLinkedcleargetParticipantgetPoolgetPoolOccupancygetPoolSizehasAbortedSizeOfreplacesetMaxSizeunlink

Field Detail

sizeback to summary
private final AtomicLong size

Constructor Detail

AtomicPoolAccessorback to summary
pack-priv AtomicPoolAccessor(Pool pool, PoolParticipant poolParticipant, SizeOfEngine sizeOfEngine, long currentSize)

Creates an atomic pool accessor with the specified properties.

Parameters
pool:Pool

pool to be accessed

poolParticipant:PoolParticipant

accessing poolParticipant

sizeOfEngine:SizeOfEngine

engine used to size objects

currentSize:long

initial size of the poolParticipant

Method Detail

addback to summary
protected long add(long sizeOf, boolean force) throws IllegalArgumentException

Implements abstract net.sf.ehcache.pool.impl.AbstractPoolAccessor.add.

Doc from net.sf.ehcache.pool.impl.AbstractPoolAccessor.add.

Add a specific number of bytes to the pool.

Parameters
sizeOf:long

number of bytes to add

force:boolean

true if the pool should accept adding the element, even if it's out of resources

Returns:long

how many bytes have been added to the pool or -1 if add failed.

Exceptions
IllegalArgumentException:
when sizeOf is negative
canAddWithoutEvictingback to summary
protected boolean canAddWithoutEvicting(long sizeOf)

Implements abstract net.sf.ehcache.pool.impl.AbstractPoolAccessor.canAddWithoutEvicting.

Doc from net.sf.ehcache.pool.impl.AbstractPoolAccessor.canAddWithoutEvicting.

Check if there is enough room in the pool to add a specific number of bytes without provoking any eviction

Parameters
sizeOf:long

number of bytes to test against

Returns:boolean

true if there is enough room left

deleteback to summary
public long delete(long sizeOf) throws IllegalArgumentException

Implements net.sf.ehcache.pool.PoolAccessor.delete.

Doc from net.sf.ehcache.pool.PoolAccessor.delete.

Delete a fixed number of bytes from the pool.

Parameters
sizeOf:long

number of bytes

Returns:long

how many bytes have been freed from the pool.

Exceptions
IllegalArgumentException:
when sizeOf is negative
doClearback to summary
protected void doClear()

Implements abstract net.sf.ehcache.pool.impl.AbstractPoolAccessor.doClear.

Doc from net.sf.ehcache.pool.impl.AbstractPoolAccessor.doClear.

Free resources used by this accessor. This method is called by clear().

getSizeback to summary
public long getSize()

Implements net.sf.ehcache.pool.PoolAccessor.getSize.

Doc from net.sf.ehcache.pool.PoolAccessor.getSize.

Return how many bytes this accessor consumes from the pool.

Returns:long

how many bytes this accessor consumes from the pool.