protected final class ConcurrentReferenceHashMap.Segment
extends java.util.concurrent.locks.ReentrantLock
Modifier and Type | Field and Description |
---|---|
private int |
count
The total number of references contained in this segment.
|
private int |
initialSize |
private ConcurrentReferenceHashMap.ReferenceManager |
referenceManager |
private ConcurrentReferenceHashMap.Reference<K,V>[] |
references
Array of references indexed using the low order bits from the hash.
|
private int |
resizeThreshold
The threshold when resizing of the references should occur.
|
Constructor and Description |
---|
ConcurrentReferenceHashMap.Segment(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clear all items from this segment.
|
private ConcurrentReferenceHashMap.Reference<K,V>[] |
createReferenceArray(int size) |
<T> T |
doTask(int hash,
java.lang.Object key,
ConcurrentReferenceHashMap.Task<T> task)
Apply an update operation to this segment.
|
private ConcurrentReferenceHashMap.Reference<K,V> |
findInChain(ConcurrentReferenceHashMap.Reference<K,V> reference,
java.lang.Object key,
int hash) |
int |
getCount() |
private int |
getIndex(int hash,
ConcurrentReferenceHashMap.Reference<K,V>[] references) |
ConcurrentReferenceHashMap.Reference<K,V> |
getReference(java.lang.Object key,
int hash,
ConcurrentReferenceHashMap.Restructure restructure) |
int |
getSize() |
private void |
restructureIfNecessary(boolean allowResize)
Restructure the underlying data structure when it becomes necessary.
|
private void |
setReferences(ConcurrentReferenceHashMap.Reference<K,V>[] references)
Replace the references with a new value, recalculating the resizeThreshold.
|
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock
private final ConcurrentReferenceHashMap.ReferenceManager referenceManager
private final int initialSize
private volatile ConcurrentReferenceHashMap.Reference<K,V>[] references
setReferences(org.springframework.util.ConcurrentReferenceHashMap.Reference<K, V>[])
to ensure that the
resizeThreshold
is maintained.private volatile int count
private int resizeThreshold
count
exceeds this value references will be resized.public ConcurrentReferenceHashMap.Segment(int initialCapacity)
public ConcurrentReferenceHashMap.Reference<K,V> getReference(java.lang.Object key, int hash, ConcurrentReferenceHashMap.Restructure restructure)
public <T> T doTask(int hash, java.lang.Object key, ConcurrentReferenceHashMap.Task<T> task)
hash
- the hash of the keykey
- the keytask
- the update operationpublic void clear()
private void restructureIfNecessary(boolean allowResize)
allowResize
- if resizing is permittedprivate ConcurrentReferenceHashMap.Reference<K,V> findInChain(ConcurrentReferenceHashMap.Reference<K,V> reference, java.lang.Object key, int hash)
private ConcurrentReferenceHashMap.Reference<K,V>[] createReferenceArray(int size)
private int getIndex(int hash, ConcurrentReferenceHashMap.Reference<K,V>[] references)
private void setReferences(ConcurrentReferenceHashMap.Reference<K,V>[] references)
references
- the new referencespublic final int getSize()
public final int getCount()