V
- the class of that is stored.public abstract class CacheTableTemplate<V> extends java.lang.Object implements MemoryHandler
MemoryHandler.Cost
Modifier and Type | Field and Description |
---|---|
protected MemoryHandler.Cost |
cost
the cost
|
protected int |
count
the count
|
protected java.lang.Object[] |
data
the data
|
protected java.lang.String |
description
the description
|
protected int |
estEmptyCount
The estimated empty count
|
protected static int |
INITIAL_CAPACITY
the capacity
|
protected int |
memoryMangerThreshold
the threshold
|
static java.lang.String |
PROPERTY_ENABLE_POINTER_CHECK
The property to enable pointer check.
|
protected java.util.concurrent.locks.ReentrantReadWriteLock |
rwLock |
protected int |
unallocated
the number unallocated
|
Constructor and Description |
---|
CacheTableTemplate(java.lang.String description,
MemoryHandler.Cost theCost)
create a new cache table.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkRegister()
check registered
|
void |
clear()
Removes all mappings from this map.
|
void |
compact()
Compact
|
boolean |
containsValue(V value)
Returns true if this map maps one or more keys to the
specified value.
|
protected abstract InterfaceEntry[] |
createArray(int size)
Create the underlying entry array
|
long |
freeMemory(double requiredPercent)
When called if the items are stored as softRefernces
and in tidy up mode then just clear the ones that
have being removed.
|
int |
getAverageSize()
The estimated average size.
|
MemoryHandler.Cost |
getCost()
The cost of this cache table.
|
java.lang.String |
getDescription()
gets the description of this cache table.
|
long |
getEstimatedSize()
The estimated amount of memory held by this cache table.
|
int |
getHardLinkCount()
The number of entries that have hard links.
|
long |
getLastAccessed()
The last time this cache table was accessed.
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
long |
panicFreeMemory()
Clear all memory ASAP.
|
long |
queuedFreeMemory(double requiredPercent)
The queued called to freeMemory which is needed to prevent a deadlock.
|
protected int |
rehash(int indexTemp,
int hash)
Rehashes the contents of this map into a new HashMap instance
with a larger capacity.
|
protected void |
removeElement(InterfaceEntry current,
int pos,
InterfaceEntry prev,
boolean updateUnallocated) |
void |
setAverageSize(int size)
Sets the estimated average size of the objects held.
|
void |
setMayReleaseReferences(boolean flag)
The default behavior of a cache table is to not release objects that are
still referred to elsewhere in the system when release memory is called.
|
void |
setThreshold(int count)
sets the threshold to register with the Memory Manager
|
int |
size()
Returns the number of key-value mappings in this map.
|
void |
stats(StatsCollector collector) |
long |
tidyUp()
Tidy up the memory handler
|
protected void |
tidyUpRequired()
tidy up
|
java.lang.String |
toString()
The description of this cache table
|
protected void |
touch(InterfaceEntry e) |
protected final java.util.concurrent.locks.ReentrantReadWriteLock rwLock
protected MemoryHandler.Cost cost
protected int estEmptyCount
protected int unallocated
protected int memoryMangerThreshold
protected java.lang.String description
protected java.lang.Object[] data
protected int count
protected static final int INITIAL_CAPACITY
public static final java.lang.String PROPERTY_ENABLE_POINTER_CHECK
public CacheTableTemplate(@Nonnull java.lang.String description, @Nonnull MemoryHandler.Cost theCost)
description
- the description of the cache table.theCost
- the relative cost of this cache table.public void setMayReleaseReferences(boolean flag)
flag
- may release ?public final void setThreshold(int count)
count
- the number of elements before we register with the memory manager.public void stats(@Nullable StatsCollector collector)
collector
- the collector@CheckReturnValue @Nonnull public java.lang.String getDescription()
@CheckReturnValue @Nonnull public final MemoryHandler.Cost getCost()
getCost
in interface MemoryHandler
@CheckReturnValue @Nonnegative public final int size()
@CheckReturnValue @Nonnegative public final int getHardLinkCount()
@CheckReturnValue public final boolean isEmpty()
@CheckReturnValue public final boolean containsValue(@Nonnull V value)
value
- value whose presence in this map is to be tested.public final void clear()
@CheckReturnValue public final long getLastAccessed()
getLastAccessed
in interface MemoryHandler
public final void setAverageSize(@Nonnegative int size)
size
- the estimated average size.@CheckReturnValue @Nonnegative public final int getAverageSize()
@CheckReturnValue @Nonnull public java.lang.String toString()
toString
in class java.lang.Object
@CheckReturnValue @Nonnegative public final long getEstimatedSize()
getEstimatedSize
in interface MemoryHandler
@Nonnegative public final long freeMemory(@Nonnegative double requiredPercent)
freeMemory
in interface MemoryHandler
requiredPercent
- The required percent to free.@Nonnegative public long panicFreeMemory()
panicFreeMemory
in interface MemoryHandler
@Nonnegative public final long queuedFreeMemory(double requiredPercent)
queuedFreeMemory
in interface MemoryHandler
requiredPercent
- The memory to freepublic void compact()
@Nonnegative public final long tidyUp()
MemoryHandler
tidyUp
in interface MemoryHandler
protected void tidyUpRequired()
protected final void removeElement(InterfaceEntry current, int pos, InterfaceEntry prev, boolean updateUnallocated)
current
- the interfacepos
- the positionprev
- the previous entryupdateUnallocated
- update the unallocatedprotected final void checkRegister()
protected final void touch(InterfaceEntry e)
e
- The entry to touch.protected abstract InterfaceEntry[] createArray(int size)
size
- the number of entries to createprotected final int rehash(int indexTemp, int hash)
indexTemp
- the indexhash
- the hash codestSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.