480 |
|
|
481 |
|
/** For serialization compatibility. */ |
482 |
|
private static final ObjectStreamField[] serialPersistentFields = { |
483 |
< |
new ObjectStreamField("segments", Segment[].class) |
483 |
> |
new ObjectStreamField("segments", Segment[].class), |
484 |
> |
new ObjectStreamField("segmentMask", Integer.TYPE), |
485 |
> |
new ObjectStreamField("segmentShift", Integer.TYPE) |
486 |
|
}; |
487 |
|
|
488 |
|
/* ---------------- Counters -------------- */ |
2497 |
|
if ((b = batch) < 0) { // force initialization |
2498 |
|
int sp = (((pool = getPool()) == null) ? |
2499 |
|
ForkJoinPool.getCommonPoolParallelism() : |
2500 |
< |
pool.getParallelism()) << 3; // slack of 8 |
2500 |
> |
pool.getParallelism()) << 2; // slack of 4 |
2501 |
|
long n = map.sumCount(); |
2502 |
|
b = (n <= 0L) ? 0 : (n < (long)sp) ? (int)n : sp; |
2503 |
|
} |
3306 |
|
(java.io.ObjectOutputStream s) |
3307 |
|
throws java.io.IOException { |
3308 |
|
// For serialization compatibility |
3309 |
+ |
// Emulate segment calculation from previous version of this class |
3310 |
+ |
int sshift = 0; |
3311 |
+ |
int ssize = 1; |
3312 |
+ |
while (ssize < DEFAULT_CONCURRENCY_LEVEL) { |
3313 |
+ |
++sshift; |
3314 |
+ |
ssize <<= 1; |
3315 |
+ |
} |
3316 |
+ |
int segmentShift = 32 - sshift; |
3317 |
+ |
int segmentMask = ssize - 1; |
3318 |
|
Segment<K,V>[] segments = (Segment<K,V>[]) |
3319 |
|
new Segment<?,?>[DEFAULT_CONCURRENCY_LEVEL]; |
3320 |
|
for (int i = 0; i < segments.length; ++i) |
3321 |
|
segments[i] = new Segment<K,V>(LOAD_FACTOR); |
3322 |
|
s.putFields().put("segments", segments); |
3323 |
+ |
s.putFields().put("segmentShift", segmentShift); |
3324 |
+ |
s.putFields().put("segmentMask", segmentMask); |
3325 |
+ |
|
3326 |
|
s.writeFields(); |
3327 |
|
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
3328 |
|
V v; |
4100 |
|
return r; |
4101 |
|
} |
4102 |
|
|
4103 |
+ |
// Overrides of other default Map methods |
4104 |
+ |
|
4105 |
+ |
public void forEach(BiConsumer<? super K, ? super V> action) { |
4106 |
+ |
forEachSequentially(action); |
4107 |
+ |
} |
4108 |
+ |
|
4109 |
+ |
public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { |
4110 |
+ |
if (function == null) throw new NullPointerException(); |
4111 |
+ |
Traverser<K,V,Object> it = new Traverser<K,V,Object>(this); |
4112 |
+ |
V v; |
4113 |
+ |
while ((v = it.advanceValue()) != null) { |
4114 |
+ |
K k = it.nextKey; |
4115 |
+ |
internalPut(k, function.apply(k, v), false); |
4116 |
+ |
} |
4117 |
+ |
} |
4118 |
+ |
|
4119 |
|
// Parallel bulk operations |
4120 |
|
|
4121 |
|
/** |