类 ConcurrentReferenceHashMap.Segment

java.lang.Object
java.util.concurrent.locks.ReentrantLock
cn.taketoday.util.ConcurrentReferenceHashMap.Segment
所有已实现的接口:
Serializable, Lock
封闭类:
ConcurrentReferenceHashMap<K,V>

protected final class ConcurrentReferenceHashMap.Segment extends ReentrantLock
A single segment used to divide the map to allow better concurrent performance.
另请参阅:
  • 字段详细资料

    • referenceManager

      private final ConcurrentReferenceHashMap<K,V>.ReferenceManager referenceManager
    • initialSize

      private final int initialSize
    • references

      private volatile ConcurrentReferenceHashMap.Reference<K,V>[] references
      Array of references indexed using the low order bits from the hash. This property should only be set along with resizeThreshold.
    • count

      private final AtomicInteger 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 resizeThreshold
      The threshold when resizing of the references should occur. When count exceeds this value references will be resized.
  • 构造器详细资料

    • Segment

      public Segment(int initialSize, int resizeThreshold)
  • 方法详细资料

    • getReference

    • 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 key
      key - the key
      task - 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 final int getSize()
      Return the size of the current references array.
    • getCount

      public final int getCount()
      Return the total number of references in this segment.