Package org.jboss.logmanager
Class ConcurrentReferenceHashMap.Segment<K,V>
java.lang.Object
java.util.concurrent.locks.ReentrantLock
org.jboss.logmanager.ConcurrentReferenceHashMap.Segment<K,V>
- All Implemented Interfaces:
Serializable
,Lock
- Enclosing class:
ConcurrentReferenceHashMap<K,
V>
static final class ConcurrentReferenceHashMap.Segment<K,V>
extends ReentrantLock
implements Serializable
Segments are specialized versions of hash tables. This
subclasses from ReentrantLock opportunistically, just to
simplify some locking and avoid separate construction.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
The number of elements in this segment's region.(package private) final boolean
(package private) final ConcurrentReferenceHashMap.ReferenceType
(package private) final float
The load factor for the hash table.(package private) int
Number of updates that alter the size of the table.(package private) ReferenceQueue
<Object> The collected weak-key reference queue for this segment.private static final long
(package private) ConcurrentReferenceHashMap.HashEntry<K,
V>[] The per-segment table.(package private) int
The table is rehashed when its size exceeds this threshold.(package private) final ConcurrentReferenceHashMap.ReferenceType
-
Constructor Summary
ConstructorsConstructorDescriptionSegment
(int initialCapacity, float lf, ConcurrentReferenceHashMap.ReferenceType keyType, ConcurrentReferenceHashMap.ReferenceType valueType, boolean identityComparisons) -
Method Summary
Modifier and TypeMethodDescription(package private) void
clear()
(package private) boolean
containsKey
(Object key, int hash) (package private) boolean
containsValue
(Object value) (package private) V
(package private) ConcurrentReferenceHashMap.HashEntry
<K, V> getFirst
(int hash) Returns properly casted first entry of bin for given hash.private boolean
(package private) static final <K,
V> ConcurrentReferenceHashMap.Segment<K, V>[] newArray
(int i) (package private) ConcurrentReferenceHashMap.HashEntry
<K, V> newHashEntry
(K key, int hash, ConcurrentReferenceHashMap.HashEntry<K, V> next, V value) (package private) V
(package private) V
Reads value field of an entry under lock.(package private) int
rehash()
(package private) V
Remove; match on key only if value null, else match both.(package private) final void
(package private) V
(package private) boolean
(package private) void
setTable
(ConcurrentReferenceHashMap.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 Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
count
transient volatile int countThe number of elements in this segment's region. -
modCount
transient int modCountNumber 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
transient int thresholdThe table is rehashed when its size exceeds this threshold. (The value of this field is always (int)(capacity * loadFactor).) -
table
The per-segment table. -
loadFactor
final float loadFactorThe 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. -
refQueue
The collected weak-key reference queue for this segment. This should be (re)initialized whenever table is assigned, -
keyType
-
valueType
-
identityComparisons
final boolean identityComparisons
-
-
Constructor Details
-
Segment
Segment(int initialCapacity, float lf, ConcurrentReferenceHashMap.ReferenceType keyType, ConcurrentReferenceHashMap.ReferenceType valueType, boolean identityComparisons)
-
-
Method Details
-
newArray
-
keyEq
-
setTable
Sets table to new HashEntry array. Call only while holding lock or in constructor. -
getFirst
Returns properly casted first entry of bin for given hash. -
newHashEntry
ConcurrentReferenceHashMap.HashEntry<K,V> newHashEntry(K key, int hash, ConcurrentReferenceHashMap.HashEntry<K, V> next, V value) -
readValueUnderLock
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
-
containsKey
-
containsValue
-
replace
-
replace
-
put
-
rehash
int rehash() -
remove
Remove; match on key only if value null, else match both. -
removeStale
final void removeStale() -
clear
void clear()
-