Package org.jboss.netty.util.internal
Class ConcurrentIdentityHashMap.Segment<K,V>
- java.lang.Object
-
- java.util.concurrent.locks.ReentrantLock
-
- org.jboss.netty.util.internal.ConcurrentIdentityHashMap.Segment<K,V>
-
- All Implemented Interfaces:
java.io.Serializable,java.util.concurrent.locks.Lock
- Enclosing class:
- ConcurrentIdentityHashMap<K,V>
static final class ConcurrentIdentityHashMap.Segment<K,V> extends java.util.concurrent.locks.ReentrantLockSegments are specialized versions of hash tables. This subclasses from ReentrantLock opportunistically, just to simplify some locking and avoid separate construction.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intcountThe number of elements in this segment's region.(package private) floatloadFactorThe load factor for the hash table.(package private) intmodCountNumber of updates that alter the size of the table.private static longserialVersionUID(package private) ConcurrentIdentityHashMap.HashEntry<K,V>[]tableThe per-segment table.(package private) intthresholdThe table is rehashed when its size exceeds this threshold.
-
Constructor Summary
Constructors Constructor Description Segment(int initialCapacity, float lf)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidclear()(package private) booleancontainsKey(java.lang.Object key, int hash)(package private) booleancontainsValue(java.lang.Object value)(package private) Vget(java.lang.Object key, int hash)(package private) ConcurrentIdentityHashMap.HashEntry<K,V>getFirst(int hash)Returns properly casted first entry of bin for given hash.private static booleankeyEq(java.lang.Object src, java.lang.Object dest)(package private) static <K,V>
ConcurrentIdentityHashMap.Segment<K,V>[]newArray(int i)(package private) ConcurrentIdentityHashMap.HashEntry<K,V>newHashEntry(K key, int hash, ConcurrentIdentityHashMap.HashEntry<K,V> next, V value)(package private) Vput(K key, int hash, V value, boolean onlyIfAbsent)(package private) VreadValueUnderLock(ConcurrentIdentityHashMap.HashEntry<K,V> e)Reads value field of an entry under lock.(package private) intrehash()(package private) Vremove(java.lang.Object key, int hash, java.lang.Object value, boolean refRemove)Remove; match on key only if value null, else match both.(package private) Vreplace(K key, int hash, V newValue)(package private) booleanreplace(K key, int hash, V oldValue, V newValue)(package private) voidsetTable(ConcurrentIdentityHashMap.HashEntry<K,V>[] newTable)Sets table to new HashEntry array.-
Methods inherited from class java.util.concurrent.locks.ReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
count
transient volatile int count
The number of elements in this segment's region.
-
modCount
int modCount
Number of updates that alter the size of the table. This is used during bulk-read methods to make sure they see a consistent snapshot: If modCounts change during a traversal of segments computing size or checking containsValue, then we might have an inconsistent view of state so (usually) must retry.
-
threshold
int threshold
The table is rehashed when its size exceeds this threshold. (The value of this field is always (capacity * loadFactor).)
-
table
transient volatile ConcurrentIdentityHashMap.HashEntry<K,V>[] table
The per-segment table.
-
loadFactor
final float loadFactor
The load factor for the hash table. Even though this value is same for all segments, it is replicated to avoid needing links to outer object.
-
-
Method Detail
-
newArray
static <K,V> ConcurrentIdentityHashMap.Segment<K,V>[] newArray(int i)
-
keyEq
private static boolean keyEq(java.lang.Object src, java.lang.Object dest)
-
setTable
void setTable(ConcurrentIdentityHashMap.HashEntry<K,V>[] newTable)
Sets table to new HashEntry array. Call only while holding lock or in constructor.
-
getFirst
ConcurrentIdentityHashMap.HashEntry<K,V> getFirst(int hash)
Returns properly casted first entry of bin for given hash.
-
newHashEntry
ConcurrentIdentityHashMap.HashEntry<K,V> newHashEntry(K key, int hash, ConcurrentIdentityHashMap.HashEntry<K,V> next, V value)
-
readValueUnderLock
V readValueUnderLock(ConcurrentIdentityHashMap.HashEntry<K,V> e)
Reads value field of an entry under lock. Called if value field ever appears to be null. This is possible only if a compiler happens to reorder a HashEntry initialization with its table assignment, which is legal under memory model but is not known to ever occur.
-
get
V get(java.lang.Object key, int hash)
-
containsKey
boolean containsKey(java.lang.Object key, int hash)
-
containsValue
boolean containsValue(java.lang.Object value)
-
rehash
int rehash()
-
remove
V remove(java.lang.Object key, int hash, java.lang.Object value, boolean refRemove)
Remove; match on key only if value null, else match both.
-
clear
void clear()
-
-