类 ConcurrentReferenceHashMap.Segment
java.lang.Object
java.util.concurrent.locks.ReentrantLock
cn.taketoday.util.ConcurrentReferenceHashMap.Segment
- 所有已实现的接口:
Serializable,Lock
- 封闭类:
- ConcurrentReferenceHashMap<K,
V>
A single segment used to divide the map to allow better concurrent performance.
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private final AtomicIntegerThe total number of references contained in this segment.private final intprivate final ConcurrentReferenceHashMap<K,V>.ReferenceManager private ConcurrentReferenceHashMap.Reference<K,V>[] Array of references indexed using the low order bits from the hash.private intThe threshold when resizing of the references should occur. -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidclear()Clear all items from this segment.<T> TApply an update operation to this segment.intgetCount()Return the total number of references in this segment.getReference(Object key, int hash, ConcurrentReferenceHashMap.Restructure restructure) intgetSize()Return the size of the current references array.private voidrestructure(boolean allowResize, ConcurrentReferenceHashMap.Reference<K, V> ref) private voidrestructureIfNecessary(boolean allowResize) Restructure the underlying data structure when it becomes necessary.从类继承的方法 java.util.concurrent.locks.ReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock
-
字段详细资料
-
referenceManager
-
initialSize
private final int initialSize -
references
Array of references indexed using the low order bits from the hash. This property should only be set along withresizeThreshold. -
count
The total number of references contained in this segment. This includes chained references and references that have been garbage collected but not purged. -
resizeThreshold
private int resizeThresholdThe threshold when resizing of the references should occur. Whencountexceeds this value references will be resized.
-
-
构造器详细资料
-
Segment
public Segment(int initialSize, int resizeThreshold)
-
-
方法详细资料
-
getReference
@Nullable public ConcurrentReferenceHashMap.Reference<K,V> getReference(@Nullable Object key, int hash, ConcurrentReferenceHashMap.Restructure restructure) -
doTask
@Nullable public <T> T doTask(int hash, @Nullable Object key, ConcurrentReferenceHashMap<K, V>.Task<T> task) Apply an update operation to this segment. The segment will be locked during the update.- 参数:
hash- the hash of the keykey- the keytask- the update operation- 返回:
- the result of the operation
-
clear
public void clear()Clear all items from this segment. -
restructureIfNecessary
private void restructureIfNecessary(boolean allowResize) Restructure the underlying data structure when it becomes necessary. This method can increase the size of the references table as well as purge any references that have been garbage collected.- 参数:
allowResize- if resizing is permitted
-
restructure
private void restructure(boolean allowResize, @Nullable ConcurrentReferenceHashMap.Reference<K, V> ref) -
getSize
public int getSize()Return the size of the current references array. -
getCount
public int getCount()Return the total number of references in this segment.
-