567 |
|
static final int SEED_INCREMENT = 0x61c88647; |
568 |
|
|
569 |
|
/** |
570 |
< |
* Per-thread counter hash codes. Shared across all instances |
570 |
> |
* Per-thread counter hash codes. Shared across all instances. |
571 |
|
*/ |
572 |
|
static final ThreadLocal<CounterHashCode> threadCounterHashCode = |
573 |
|
new ThreadLocal<CounterHashCode>(); |
1785 |
|
} |
1786 |
|
} |
1787 |
|
if (len != 0) { |
1788 |
< |
if (len > 1) |
1788 |
> |
if (len > 1) { |
1789 |
|
addCount(delta, len); |
1790 |
+ |
delta = 0L; |
1791 |
+ |
} |
1792 |
|
break; |
1793 |
|
} |
1794 |
|
} |
3732 |
|
* result on success, else null |
3733 |
|
* @return a non-null result from applying the given search |
3734 |
|
* function on each value, or null if none |
3733 |
– |
* |
3735 |
|
*/ |
3736 |
|
public <U> U searchValuesSequentially |
3737 |
|
(Fun<? super V, ? extends U> searchFunction) { |
4338 |
|
* result on success, else null |
4339 |
|
* @return a non-null result from applying the given search |
4340 |
|
* function on each value, or null if none |
4340 |
– |
* |
4341 |
|
*/ |
4342 |
|
public <U> U searchValuesInParallel |
4343 |
|
(Fun<? super V, ? extends U> searchFunction) { |
4579 |
|
/** |
4580 |
|
* Base class for views. |
4581 |
|
*/ |
4582 |
< |
static abstract class CHMView<K, V> { |
4582 |
> |
abstract static class CHMView<K, V> { |
4583 |
|
final ConcurrentHashMapV8<K, V> map; |
4584 |
|
CHMView(ConcurrentHashMapV8<K, V> map) { this.map = map; } |
4585 |
|
|
4595 |
|
public final void clear() { map.clear(); } |
4596 |
|
|
4597 |
|
// implementations below rely on concrete classes supplying these |
4598 |
< |
abstract public Iterator<?> iterator(); |
4599 |
< |
abstract public boolean contains(Object o); |
4600 |
< |
abstract public boolean remove(Object o); |
4598 |
> |
public abstract Iterator<?> iterator(); |
4599 |
> |
public abstract boolean contains(Object o); |
4600 |
> |
public abstract boolean remove(Object o); |
4601 |
|
|
4602 |
|
private static final String oomeMsg = "Required array size too large"; |
4603 |
|
|
6806 |
|
private static final int ASHIFT; |
6807 |
|
|
6808 |
|
static { |
6809 |
– |
int ss; |
6809 |
|
try { |
6810 |
|
U = getUnsafe(); |
6811 |
|
Class<?> k = ConcurrentHashMapV8.class; |
6824 |
|
(ck.getDeclaredField("value")); |
6825 |
|
Class<?> sc = Node[].class; |
6826 |
|
ABASE = U.arrayBaseOffset(sc); |
6827 |
< |
ss = U.arrayIndexScale(sc); |
6828 |
< |
ASHIFT = 31 - Integer.numberOfLeadingZeros(ss); |
6827 |
> |
int scale = U.arrayIndexScale(sc); |
6828 |
> |
if ((scale & (scale - 1)) != 0) |
6829 |
> |
throw new Error("data type scale not a power of two"); |
6830 |
> |
ASHIFT = 31 - Integer.numberOfLeadingZeros(scale); |
6831 |
|
} catch (Exception e) { |
6832 |
|
throw new Error(e); |
6833 |
|
} |
6833 |
– |
if ((ss & (ss-1)) != 0) |
6834 |
– |
throw new Error("data type scale not a power of two"); |
6834 |
|
} |
6835 |
|
|
6836 |
|
/** |
6843 |
|
private static sun.misc.Unsafe getUnsafe() { |
6844 |
|
try { |
6845 |
|
return sun.misc.Unsafe.getUnsafe(); |
6846 |
< |
} catch (SecurityException se) { |
6847 |
< |
try { |
6848 |
< |
return java.security.AccessController.doPrivileged |
6849 |
< |
(new java.security |
6850 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
6851 |
< |
public sun.misc.Unsafe run() throws Exception { |
6852 |
< |
java.lang.reflect.Field f = sun.misc |
6853 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
6854 |
< |
f.setAccessible(true); |
6855 |
< |
return (sun.misc.Unsafe) f.get(null); |
6856 |
< |
}}); |
6857 |
< |
} catch (java.security.PrivilegedActionException e) { |
6858 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
6859 |
< |
e.getCause()); |
6860 |
< |
} |
6846 |
> |
} catch (SecurityException tryReflectionInstead) {} |
6847 |
> |
try { |
6848 |
> |
return java.security.AccessController.doPrivileged |
6849 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
6850 |
> |
public sun.misc.Unsafe run() throws Exception { |
6851 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
6852 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
6853 |
> |
f.setAccessible(true); |
6854 |
> |
Object x = f.get(null); |
6855 |
> |
if (k.isInstance(x)) |
6856 |
> |
return k.cast(x); |
6857 |
> |
} |
6858 |
> |
throw new NoSuchFieldError("the Unsafe"); |
6859 |
> |
}}); |
6860 |
> |
} catch (java.security.PrivilegedActionException e) { |
6861 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
6862 |
> |
e.getCause()); |
6863 |
|
} |
6864 |
|
} |
6865 |
|
} |