|
|
@ -179,10 +179,13 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen |
|
|
|
int size = 1 << this.shift; |
|
|
|
int size = 1 << this.shift; |
|
|
|
this.referenceType = referenceType; |
|
|
|
this.referenceType = referenceType; |
|
|
|
int roundedUpSegmentCapacity = (int) ((initialCapacity + size - 1L) / size); |
|
|
|
int roundedUpSegmentCapacity = (int) ((initialCapacity + size - 1L) / size); |
|
|
|
this.segments = (Segment[]) Array.newInstance(Segment.class, size); |
|
|
|
int initialSize = 1 << calculateShift(roundedUpSegmentCapacity, MAXIMUM_SEGMENT_SIZE); |
|
|
|
for (int i = 0; i < this.segments.length; i++) { |
|
|
|
Segment[] segments = (Segment[]) Array.newInstance(Segment.class, size); |
|
|
|
this.segments[i] = new Segment(roundedUpSegmentCapacity); |
|
|
|
int resizeThreshold = (int) (initialSize * getLoadFactor()); |
|
|
|
|
|
|
|
for (int i = 0; i < segments.length; i++) { |
|
|
|
|
|
|
|
segments[i] = new Segment(initialSize, resizeThreshold); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this.segments = segments; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -481,11 +484,11 @@ public class ConcurrentReferenceHashMap<K, V> extends AbstractMap<K, V> implemen |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private int resizeThreshold; |
|
|
|
private int resizeThreshold; |
|
|
|
|
|
|
|
|
|
|
|
public Segment(int initialCapacity) { |
|
|
|
public Segment(int initialSize, int resizeThreshold) { |
|
|
|
this.referenceManager = createReferenceManager(); |
|
|
|
this.referenceManager = createReferenceManager(); |
|
|
|
this.initialSize = 1 << calculateShift(initialCapacity, MAXIMUM_SEGMENT_SIZE); |
|
|
|
this.initialSize = initialSize; |
|
|
|
this.references = createReferenceArray(this.initialSize); |
|
|
|
this.references = createReferenceArray(initialSize); |
|
|
|
this.resizeThreshold = (int) (this.references.length * getLoadFactor()); |
|
|
|
this.resizeThreshold = resizeThreshold; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|