5 |
|
*/ |
6 |
|
|
7 |
|
package extra166y; |
8 |
+ |
|
9 |
|
import java.lang.ref.*; |
10 |
|
import java.lang.reflect.*; |
11 |
|
import java.io.*; |
20 |
|
* user-supplied computational methods for setting and updating |
21 |
|
* values. In particular: <ul> |
22 |
|
* |
23 |
< |
* <li> Identity-based, Equality-based or User-definable {@link |
24 |
< |
* Equivalence}-based comparisons controlling membership. |
23 |
> |
* <li>Identity-based, Equality-based or User-definable {@link |
24 |
> |
* Equivalence}-based comparisons controlling membership. |
25 |
|
* |
26 |
< |
* <li> {@linkplain SoftReference Soft}, {@linkplain |
27 |
< |
* WeakReference weak} or strong (regular) keys and values. |
26 |
> |
* <li>{@linkplain SoftReference Soft}, {@linkplain |
27 |
> |
* WeakReference weak} or strong (regular) keys and values. |
28 |
|
* |
29 |
< |
* <li> User-definable {@code MappingFunctions} that may be |
30 |
< |
* used in method {@link |
31 |
< |
* CustomConcurrentHashMap#computeIfAbsent} to atomically |
32 |
< |
* establish a computed value, along with |
33 |
< |
* {@code RemappingFunctions} that can be used in method |
34 |
< |
* {@link CustomConcurrentHashMap#compute} to atomically |
35 |
< |
* replace values. |
29 |
> |
* <li>User-definable {@code MappingFunctions} that may be |
30 |
> |
* used in method {@link |
31 |
> |
* CustomConcurrentHashMap#computeIfAbsent} to atomically |
32 |
> |
* establish a computed value, along with |
33 |
> |
* {@code RemappingFunctions} that can be used in method |
34 |
> |
* {@link CustomConcurrentHashMap#compute} to atomically |
35 |
> |
* replace values. |
36 |
|
* |
37 |
< |
* <li>Factory methods returning specialized forms for {@code int} |
38 |
< |
* keys and/or values, that may be more space-efficient |
37 |
> |
* <li>Factory methods returning specialized forms for {@code int} |
38 |
> |
* keys and/or values, that may be more space-efficient |
39 |
|
* |
40 |
|
* </ul> |
41 |
|
* |
111 |
|
* @param <K> the type of keys maintained by this map |
112 |
|
* @param <V> the type of mapped values |
113 |
|
*/ |
114 |
< |
public class CustomConcurrentHashMap<K, V> extends AbstractMap<K, V> |
115 |
< |
implements ConcurrentMap<K, V>, Serializable { |
114 |
> |
public class CustomConcurrentHashMap<K,V> extends AbstractMap<K,V> |
115 |
> |
implements ConcurrentMap<K,V>, Serializable { |
116 |
|
private static final long serialVersionUID = 7249069246764182397L; |
117 |
|
|
118 |
|
/* |
225 |
|
|
226 |
|
/** |
227 |
|
* A function computing a mapping from the given key to a value, |
228 |
< |
* or {@code null} if there is no mapping. |
228 |
> |
* or {@code null} if there is no mapping. |
229 |
|
*/ |
230 |
< |
public static interface MappingFunction<K, V> { |
230 |
> |
public static interface MappingFunction<K,V> { |
231 |
|
/** |
232 |
|
* Returns a value for the given key, or null if there is no |
233 |
|
* mapping. If this function throws an (unchecked) exception, |
246 |
|
/** |
247 |
|
* A function computing a new mapping from the given key and its |
248 |
|
* current value to a new value, or {@code null} if there is |
249 |
< |
* no mapping |
249 |
> |
* no mapping. |
250 |
|
*/ |
251 |
< |
public static interface RemappingFunction<K, V> { |
251 |
> |
public static interface RemappingFunction<K,V> { |
252 |
|
/** |
253 |
|
* Returns a new value for the given key and its current, or |
254 |
|
* null if there is no mapping. |
345 |
|
* Records the linkage to be returned by the next call to getLinkage. |
346 |
|
* @param linkage the linkage |
347 |
|
*/ |
348 |
< |
void setLinkage(Node r); |
348 |
> |
void setLinkage(Node linkage); |
349 |
|
} |
350 |
|
|
351 |
|
/** |
352 |
|
* Each Segment holds a count and table corresponding to a segment |
353 |
|
* of the table. This class contains only those methods for |
354 |
|
* directly assigning these fields, which must only be called |
355 |
< |
* while holding locks |
355 |
> |
* while holding locks. |
356 |
|
*/ |
357 |
|
static final class Segment extends ReentrantLock { |
358 |
|
volatile Node[] table; |
387 |
|
} |
388 |
|
|
389 |
|
/** |
390 |
< |
* See the similar code in ConcurrentHashMap for explanation |
390 |
> |
* See the similar code in ConcurrentHashMap for explanation. |
391 |
|
*/ |
392 |
|
final Node[] resizeTable(CustomConcurrentHashMap cchm) { |
393 |
|
Node[] oldTable = table; |
394 |
|
if (oldTable == null) |
395 |
< |
return table = (Node[]) |
395 |
< |
new Node[cchm.initialSegmentCapacity]; |
395 |
> |
return table = new Node[cchm.initialSegmentCapacity]; |
396 |
|
|
397 |
|
int oldCapacity = oldTable.length; |
398 |
|
if (oldCapacity >= MAX_SEGMENT_CAPACITY) |
399 |
|
return oldTable; |
400 |
< |
Node[] newTable = |
401 |
< |
(Node[])new Node[oldCapacity<<1]; |
400 |
> |
Node[] newTable = new Node[oldCapacity<<1]; |
401 |
|
int sizeMask = newTable.length - 1; |
402 |
|
NodeFactory fac = cchm.factory; |
403 |
|
for (int i = 0; i < oldCapacity ; i++) { |
539 |
|
capacity = MAX_SEGMENT_CAPACITY; |
540 |
|
this.initialSegmentCapacity = capacity; |
541 |
|
} |
542 |
< |
this.segments = (Segment[])new Segment[NSEGMENTS]; |
542 |
> |
this.segments = new Segment[NSEGMENTS]; |
543 |
|
} |
544 |
|
|
545 |
|
/** |
680 |
|
* Returns {@code true} if this map contains a key equivalent to |
681 |
|
* the given key with respect to this map's key Equivalence. |
682 |
|
* |
683 |
< |
* @param key possible key |
683 |
> |
* @param key possible key |
684 |
|
* @return {@code true} if this map contains the specified key |
685 |
|
* @throws NullPointerException if the specified key is null |
686 |
|
*/ |
698 |
|
* key with respect to this map's key Equivalence, or {@code null} |
699 |
|
* if no such mapping exists. |
700 |
|
* |
701 |
< |
* @param key possible key |
702 |
< |
* @return the value associated with the key or {@code null} if |
703 |
< |
* there is no mapping. |
701 |
> |
* @param key possible key |
702 |
> |
* @return the value associated with the key, or {@code null} if |
703 |
> |
* there is no mapping |
704 |
|
* @throws NullPointerException if the specified key is null |
705 |
|
*/ |
706 |
|
public V get(Object key) { |
1091 |
|
* @param mappingFunction the function to compute a value |
1092 |
|
* @return the current (existing or computed) value associated with |
1093 |
|
* the specified key, or {@code null} if the computation |
1094 |
< |
* returned {@code null}. |
1094 |
> |
* returned {@code null} |
1095 |
|
* @throws NullPointerException if the specified key or mappingFunction |
1096 |
< |
* is null, |
1096 |
> |
* is null |
1097 |
|
* @throws RuntimeException or Error if the mappingFunction does so, |
1098 |
< |
* in which case the mapping is left unestablished. |
1098 |
> |
* in which case the mapping is left unestablished |
1099 |
|
*/ |
1100 |
|
public V computeIfAbsent(K key, MappingFunction<? super K, ? extends V> mappingFunction) { |
1101 |
|
if (key == null || mappingFunction == null) |
1166 |
|
* @return the updated value or |
1167 |
|
* {@code null} if the computation returned {@code null} |
1168 |
|
* @throws NullPointerException if the specified key or remappingFunction |
1169 |
< |
* is null, |
1169 |
> |
* is null |
1170 |
|
* @throws RuntimeException or Error if the remappingFunction does so, |
1171 |
|
* in which case the mapping is left in its previous state |
1172 |
|
*/ |
1575 |
|
private void readObject(java.io.ObjectInputStream s) |
1576 |
|
throws IOException, ClassNotFoundException { |
1577 |
|
s.defaultReadObject(); |
1578 |
< |
this.segments = (Segment[])(new Segment[NSEGMENTS]); |
1578 |
> |
this.segments = new Segment[NSEGMENTS]; |
1579 |
|
for (;;) { |
1580 |
|
K key = (K) s.readObject(); |
1581 |
|
V value = (V) s.readObject(); |
1721 |
|
* to {@link java.lang.ref.Reference} constructors to arrange |
1722 |
|
* removal of reclaimed nodes from maps via a background thread. |
1723 |
|
* @return the reference queue associated with the background |
1724 |
< |
* cleanup thread. |
1724 |
> |
* cleanup thread |
1725 |
|
*/ |
1726 |
|
static ReferenceQueue<Object> getReclamationQueue() { |
1727 |
|
ReferenceQueue<Object> q = refQueue; |
1792 |
|
|
1793 |
|
// Strong Keys |
1794 |
|
|
1795 |
< |
static abstract class StrongKeyNode implements Node { |
1795 |
> |
abstract static class StrongKeyNode implements Node { |
1796 |
|
final Object key; |
1797 |
|
final int locator; |
1798 |
|
StrongKeyNode(int locator, Object key) { |
1804 |
|
} |
1805 |
|
|
1806 |
|
|
1807 |
< |
static abstract class StrongKeySelfValueNode |
1807 |
> |
abstract static class StrongKeySelfValueNode |
1808 |
|
extends StrongKeyNode { |
1809 |
|
StrongKeySelfValueNode(int locator, Object key) { |
1810 |
|
super(locator, key); |
1820 |
|
super(locator, key); |
1821 |
|
} |
1822 |
|
public final Node getLinkage() { return null; } |
1823 |
< |
public final void setLinkage(Node r) { } |
1823 |
> |
public final void setLinkage(Node linkage) { } |
1824 |
|
} |
1825 |
|
|
1826 |
|
static final class LinkedStrongKeySelfValueNode |
1832 |
|
this.linkage = linkage; |
1833 |
|
} |
1834 |
|
public final Node getLinkage() { return linkage; } |
1835 |
< |
public final void setLinkage(Node r) { linkage = r; } |
1835 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
1836 |
|
} |
1837 |
|
|
1838 |
|
static final class StrongKeySelfValueNodeFactory |
1851 |
|
} |
1852 |
|
} |
1853 |
|
|
1854 |
< |
static abstract class StrongKeyStrongValueNode |
1854 |
> |
abstract static class StrongKeyStrongValueNode |
1855 |
|
extends StrongKeyNode { |
1856 |
|
volatile Object value; |
1857 |
|
StrongKeyStrongValueNode(int locator, Object key, Object value) { |
1870 |
|
super(locator, key, value); |
1871 |
|
} |
1872 |
|
public final Node getLinkage() { return null; } |
1873 |
< |
public final void setLinkage(Node r) { } |
1873 |
> |
public final void setLinkage(Node linkage) { } |
1874 |
|
} |
1875 |
|
|
1876 |
|
static final class LinkedStrongKeyStrongValueNode |
1883 |
|
this.linkage = linkage; |
1884 |
|
} |
1885 |
|
public final Node getLinkage() { return linkage; } |
1886 |
< |
public final void setLinkage(Node r) { linkage = r; } |
1886 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
1887 |
|
} |
1888 |
|
|
1889 |
|
static final class StrongKeyStrongValueNodeFactory |
1904 |
|
|
1905 |
|
// ... |
1906 |
|
|
1907 |
< |
static abstract class StrongKeyIntValueNode |
1907 |
> |
abstract static class StrongKeyIntValueNode |
1908 |
|
extends StrongKeyNode { |
1909 |
|
volatile int value; |
1910 |
|
StrongKeyIntValueNode(int locator, Object key, Object value) { |
1925 |
|
super(locator, key, value); |
1926 |
|
} |
1927 |
|
public final Node getLinkage() { return null; } |
1928 |
< |
public final void setLinkage(Node r) { } |
1928 |
> |
public final void setLinkage(Node linkage) { } |
1929 |
|
} |
1930 |
|
|
1931 |
|
static final class LinkedStrongKeyIntValueNode |
1938 |
|
this.linkage = linkage; |
1939 |
|
} |
1940 |
|
public final Node getLinkage() { return linkage; } |
1941 |
< |
public final void setLinkage(Node r) { linkage = r; } |
1941 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
1942 |
|
} |
1943 |
|
|
1944 |
|
static final class StrongKeyIntValueNodeFactory |
1959 |
|
|
1960 |
|
// ... |
1961 |
|
|
1962 |
< |
static abstract class StrongKeyWeakValueNode |
1962 |
> |
abstract static class StrongKeyWeakValueNode |
1963 |
|
extends StrongKeyNode { |
1964 |
|
volatile EmbeddedWeakReference valueRef; |
1965 |
|
final CustomConcurrentHashMap cchm; |
1993 |
|
super(locator, key, value, cchm); |
1994 |
|
} |
1995 |
|
public final Node getLinkage() { return null; } |
1996 |
< |
public final void setLinkage(Node r) { } |
1996 |
> |
public final void setLinkage(Node linkage) { } |
1997 |
|
} |
1998 |
|
|
1999 |
|
static final class LinkedStrongKeyWeakValueNode |
2007 |
|
this.linkage = linkage; |
2008 |
|
} |
2009 |
|
public final Node getLinkage() { return linkage; } |
2010 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2010 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2011 |
|
} |
2012 |
|
|
2013 |
|
static final class StrongKeyWeakValueNodeFactory |
2027 |
|
} |
2028 |
|
|
2029 |
|
|
2030 |
< |
static abstract class StrongKeySoftValueNode |
2030 |
> |
abstract static class StrongKeySoftValueNode |
2031 |
|
extends StrongKeyNode { |
2032 |
|
volatile EmbeddedSoftReference valueRef; |
2033 |
|
final CustomConcurrentHashMap cchm; |
2061 |
|
super(locator, key, value, cchm); |
2062 |
|
} |
2063 |
|
public final Node getLinkage() { return null; } |
2064 |
< |
public final void setLinkage(Node r) { } |
2064 |
> |
public final void setLinkage(Node linkage) { } |
2065 |
|
} |
2066 |
|
|
2067 |
|
static final class LinkedStrongKeySoftValueNode |
2075 |
|
this.linkage = linkage; |
2076 |
|
} |
2077 |
|
public final Node getLinkage() { return linkage; } |
2078 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2078 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2079 |
|
} |
2080 |
|
|
2081 |
|
static final class StrongKeySoftValueNodeFactory |
2096 |
|
|
2097 |
|
// Weak keys |
2098 |
|
|
2099 |
< |
static abstract class WeakKeyNode extends WeakReference |
2099 |
> |
abstract static class WeakKeyNode extends WeakReference |
2100 |
|
implements Node { |
2101 |
|
final int locator; |
2102 |
|
final CustomConcurrentHashMap cchm; |
2112 |
|
} |
2113 |
|
} |
2114 |
|
|
2115 |
< |
static abstract class WeakKeySelfValueNode |
2115 |
> |
abstract static class WeakKeySelfValueNode |
2116 |
|
extends WeakKeyNode { |
2117 |
|
WeakKeySelfValueNode(int locator, Object key, |
2118 |
|
CustomConcurrentHashMap cchm) { |
2129 |
|
super(locator, key, cchm); |
2130 |
|
} |
2131 |
|
public final Node getLinkage() { return null; } |
2132 |
< |
public final void setLinkage(Node r) { } |
2132 |
> |
public final void setLinkage(Node linkage) { } |
2133 |
|
} |
2134 |
|
|
2135 |
|
static final class LinkedWeakKeySelfValueNode |
2142 |
|
this.linkage = linkage; |
2143 |
|
} |
2144 |
|
public final Node getLinkage() { return linkage; } |
2145 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2145 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2146 |
|
} |
2147 |
|
|
2148 |
|
static final class WeakKeySelfValueNodeFactory |
2162 |
|
} |
2163 |
|
|
2164 |
|
|
2165 |
< |
static abstract class WeakKeyStrongValueNode |
2165 |
> |
abstract static class WeakKeyStrongValueNode |
2166 |
|
extends WeakKeyNode { |
2167 |
|
volatile Object value; |
2168 |
|
WeakKeyStrongValueNode(int locator, Object key, Object value, |
2182 |
|
super(locator, key, value, cchm); |
2183 |
|
} |
2184 |
|
public final Node getLinkage() { return null; } |
2185 |
< |
public final void setLinkage(Node r) { } |
2185 |
> |
public final void setLinkage(Node linkage) { } |
2186 |
|
} |
2187 |
|
|
2188 |
|
static final class LinkedWeakKeyStrongValueNode |
2196 |
|
this.linkage = linkage; |
2197 |
|
} |
2198 |
|
public final Node getLinkage() { return linkage; } |
2199 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2199 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2200 |
|
} |
2201 |
|
|
2202 |
|
static final class WeakKeyStrongValueNodeFactory |
2215 |
|
} |
2216 |
|
} |
2217 |
|
|
2218 |
< |
static abstract class WeakKeyIntValueNode |
2218 |
> |
abstract static class WeakKeyIntValueNode |
2219 |
|
extends WeakKeyNode { |
2220 |
|
volatile int value; |
2221 |
|
WeakKeyIntValueNode(int locator, Object key, Object value, |
2237 |
|
super(locator, key, value, cchm); |
2238 |
|
} |
2239 |
|
public final Node getLinkage() { return null; } |
2240 |
< |
public final void setLinkage(Node r) { } |
2240 |
> |
public final void setLinkage(Node linkage) { } |
2241 |
|
} |
2242 |
|
|
2243 |
|
static final class LinkedWeakKeyIntValueNode |
2251 |
|
this.linkage = linkage; |
2252 |
|
} |
2253 |
|
public final Node getLinkage() { return linkage; } |
2254 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2254 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2255 |
|
} |
2256 |
|
|
2257 |
|
static final class WeakKeyIntValueNodeFactory |
2270 |
|
} |
2271 |
|
} |
2272 |
|
|
2273 |
< |
static abstract class WeakKeyWeakValueNode |
2273 |
> |
abstract static class WeakKeyWeakValueNode |
2274 |
|
extends WeakKeyNode { |
2275 |
|
volatile EmbeddedWeakReference valueRef; |
2276 |
|
WeakKeyWeakValueNode(int locator, Object key, Object value, |
2299 |
|
super(locator, key, value, cchm); |
2300 |
|
} |
2301 |
|
public final Node getLinkage() { return null; } |
2302 |
< |
public final void setLinkage(Node r) { } |
2302 |
> |
public final void setLinkage(Node linkage) { } |
2303 |
|
} |
2304 |
|
|
2305 |
|
static final class LinkedWeakKeyWeakValueNode |
2313 |
|
this.linkage = linkage; |
2314 |
|
} |
2315 |
|
public final Node getLinkage() { return linkage; } |
2316 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2316 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2317 |
|
} |
2318 |
|
|
2319 |
|
static final class WeakKeyWeakValueNodeFactory |
2333 |
|
} |
2334 |
|
|
2335 |
|
|
2336 |
< |
static abstract class WeakKeySoftValueNode |
2336 |
> |
abstract static class WeakKeySoftValueNode |
2337 |
|
extends WeakKeyNode { |
2338 |
|
volatile EmbeddedSoftReference valueRef; |
2339 |
|
WeakKeySoftValueNode(int locator, Object key, Object value, |
2362 |
|
super(locator, key, value, cchm); |
2363 |
|
} |
2364 |
|
public final Node getLinkage() { return null; } |
2365 |
< |
public final void setLinkage(Node r) { } |
2365 |
> |
public final void setLinkage(Node linkage) { } |
2366 |
|
} |
2367 |
|
|
2368 |
|
static final class LinkedWeakKeySoftValueNode |
2376 |
|
this.linkage = linkage; |
2377 |
|
} |
2378 |
|
public final Node getLinkage() { return linkage; } |
2379 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2379 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2380 |
|
} |
2381 |
|
|
2382 |
|
static final class WeakKeySoftValueNodeFactory |
2397 |
|
|
2398 |
|
// Soft keys |
2399 |
|
|
2400 |
< |
static abstract class SoftKeyNode extends SoftReference |
2400 |
> |
abstract static class SoftKeyNode extends SoftReference |
2401 |
|
implements Node { |
2402 |
|
final int locator; |
2403 |
|
final CustomConcurrentHashMap cchm; |
2413 |
|
} |
2414 |
|
} |
2415 |
|
|
2416 |
< |
static abstract class SoftKeySelfValueNode |
2416 |
> |
abstract static class SoftKeySelfValueNode |
2417 |
|
extends SoftKeyNode { |
2418 |
|
SoftKeySelfValueNode(int locator, Object key, |
2419 |
|
CustomConcurrentHashMap cchm) { |
2430 |
|
super(locator, key, cchm); |
2431 |
|
} |
2432 |
|
public final Node getLinkage() { return null; } |
2433 |
< |
public final void setLinkage(Node r) { } |
2433 |
> |
public final void setLinkage(Node linkage) { } |
2434 |
|
} |
2435 |
|
|
2436 |
|
static final class LinkedSoftKeySelfValueNode |
2443 |
|
this.linkage = linkage; |
2444 |
|
} |
2445 |
|
public final Node getLinkage() { return linkage; } |
2446 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2446 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2447 |
|
} |
2448 |
|
|
2449 |
|
static final class SoftKeySelfValueNodeFactory |
2463 |
|
} |
2464 |
|
|
2465 |
|
|
2466 |
< |
static abstract class SoftKeyStrongValueNode |
2466 |
> |
abstract static class SoftKeyStrongValueNode |
2467 |
|
extends SoftKeyNode { |
2468 |
|
volatile Object value; |
2469 |
|
SoftKeyStrongValueNode(int locator, Object key, Object value, |
2483 |
|
super(locator, key, value, cchm); |
2484 |
|
} |
2485 |
|
public final Node getLinkage() { return null; } |
2486 |
< |
public final void setLinkage(Node r) { } |
2486 |
> |
public final void setLinkage(Node linkage) { } |
2487 |
|
} |
2488 |
|
|
2489 |
|
static final class LinkedSoftKeyStrongValueNode |
2497 |
|
this.linkage = linkage; |
2498 |
|
} |
2499 |
|
public final Node getLinkage() { return linkage; } |
2500 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2500 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2501 |
|
} |
2502 |
|
|
2503 |
|
static final class SoftKeyStrongValueNodeFactory |
2516 |
|
} |
2517 |
|
} |
2518 |
|
|
2519 |
< |
static abstract class SoftKeyIntValueNode |
2519 |
> |
abstract static class SoftKeyIntValueNode |
2520 |
|
extends SoftKeyNode { |
2521 |
|
volatile int value; |
2522 |
|
SoftKeyIntValueNode(int locator, Object key, Object value, |
2538 |
|
super(locator, key, value, cchm); |
2539 |
|
} |
2540 |
|
public final Node getLinkage() { return null; } |
2541 |
< |
public final void setLinkage(Node r) { } |
2541 |
> |
public final void setLinkage(Node linkage) { } |
2542 |
|
} |
2543 |
|
|
2544 |
|
static final class LinkedSoftKeyIntValueNode |
2552 |
|
this.linkage = linkage; |
2553 |
|
} |
2554 |
|
public final Node getLinkage() { return linkage; } |
2555 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2555 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2556 |
|
} |
2557 |
|
|
2558 |
|
static final class SoftKeyIntValueNodeFactory |
2571 |
|
} |
2572 |
|
} |
2573 |
|
|
2574 |
< |
static abstract class SoftKeyWeakValueNode |
2574 |
> |
abstract static class SoftKeyWeakValueNode |
2575 |
|
extends SoftKeyNode { |
2576 |
|
volatile EmbeddedWeakReference valueRef; |
2577 |
|
SoftKeyWeakValueNode(int locator, Object key, Object value, |
2600 |
|
super(locator, key, value, cchm); |
2601 |
|
} |
2602 |
|
public final Node getLinkage() { return null; } |
2603 |
< |
public final void setLinkage(Node r) { } |
2603 |
> |
public final void setLinkage(Node linkage) { } |
2604 |
|
} |
2605 |
|
|
2606 |
|
static final class LinkedSoftKeyWeakValueNode |
2614 |
|
this.linkage = linkage; |
2615 |
|
} |
2616 |
|
public final Node getLinkage() { return linkage; } |
2617 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2617 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2618 |
|
} |
2619 |
|
|
2620 |
|
static final class SoftKeyWeakValueNodeFactory |
2634 |
|
} |
2635 |
|
|
2636 |
|
|
2637 |
< |
static abstract class SoftKeySoftValueNode |
2637 |
> |
abstract static class SoftKeySoftValueNode |
2638 |
|
extends SoftKeyNode { |
2639 |
|
volatile EmbeddedSoftReference valueRef; |
2640 |
|
SoftKeySoftValueNode(int locator, Object key, Object value, |
2663 |
|
super(locator, key, value, cchm); |
2664 |
|
} |
2665 |
|
public final Node getLinkage() { return null; } |
2666 |
< |
public final void setLinkage(Node r) { } |
2666 |
> |
public final void setLinkage(Node linkage) { } |
2667 |
|
} |
2668 |
|
|
2669 |
|
static final class LinkedSoftKeySoftValueNode |
2677 |
|
this.linkage = linkage; |
2678 |
|
} |
2679 |
|
public final Node getLinkage() { return linkage; } |
2680 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2680 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2681 |
|
} |
2682 |
|
|
2683 |
|
static final class SoftKeySoftValueNodeFactory |
2696 |
|
} |
2697 |
|
} |
2698 |
|
|
2699 |
< |
static abstract class IntKeyNode implements Node { |
2699 |
> |
abstract static class IntKeyNode implements Node { |
2700 |
|
final int key; |
2701 |
|
IntKeyNode(int locator, Object key) { |
2702 |
|
this.key = ((Integer)key).intValue(); |
2706 |
|
} |
2707 |
|
|
2708 |
|
|
2709 |
< |
static abstract class IntKeySelfValueNode |
2709 |
> |
abstract static class IntKeySelfValueNode |
2710 |
|
extends IntKeyNode { |
2711 |
|
IntKeySelfValueNode(int locator, Object key) { |
2712 |
|
super(locator, key); |
2722 |
|
super(locator, key); |
2723 |
|
} |
2724 |
|
public final Node getLinkage() { return null; } |
2725 |
< |
public final void setLinkage(Node r) { } |
2725 |
> |
public final void setLinkage(Node linkage) { } |
2726 |
|
} |
2727 |
|
|
2728 |
|
static final class LinkedIntKeySelfValueNode |
2734 |
|
this.linkage = linkage; |
2735 |
|
} |
2736 |
|
public final Node getLinkage() { return linkage; } |
2737 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2737 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2738 |
|
} |
2739 |
|
|
2740 |
|
static final class IntKeySelfValueNodeFactory |
2753 |
|
} |
2754 |
|
} |
2755 |
|
|
2756 |
< |
static abstract class IntKeyStrongValueNode |
2756 |
> |
abstract static class IntKeyStrongValueNode |
2757 |
|
extends IntKeyNode { |
2758 |
|
volatile Object value; |
2759 |
|
IntKeyStrongValueNode(int locator, Object key, Object value) { |
2772 |
|
super(locator, key, value); |
2773 |
|
} |
2774 |
|
public final Node getLinkage() { return null; } |
2775 |
< |
public final void setLinkage(Node r) { } |
2775 |
> |
public final void setLinkage(Node linkage) { } |
2776 |
|
} |
2777 |
|
|
2778 |
|
static final class LinkedIntKeyStrongValueNode |
2785 |
|
this.linkage = linkage; |
2786 |
|
} |
2787 |
|
public final Node getLinkage() { return linkage; } |
2788 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2788 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2789 |
|
} |
2790 |
|
|
2791 |
|
static final class IntKeyStrongValueNodeFactory |
2804 |
|
} |
2805 |
|
} |
2806 |
|
|
2807 |
< |
static abstract class IntKeyIntValueNode |
2807 |
> |
abstract static class IntKeyIntValueNode |
2808 |
|
extends IntKeyNode { |
2809 |
|
volatile int value; |
2810 |
|
IntKeyIntValueNode(int locator, Object key, Object value) { |
2825 |
|
super(locator, key, value); |
2826 |
|
} |
2827 |
|
public final Node getLinkage() { return null; } |
2828 |
< |
public final void setLinkage(Node r) { } |
2828 |
> |
public final void setLinkage(Node linkage) { } |
2829 |
|
} |
2830 |
|
|
2831 |
|
static final class LinkedIntKeyIntValueNode |
2838 |
|
this.linkage = linkage; |
2839 |
|
} |
2840 |
|
public final Node getLinkage() { return linkage; } |
2841 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2841 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2842 |
|
} |
2843 |
|
|
2844 |
|
static final class IntKeyIntValueNodeFactory |
2857 |
|
} |
2858 |
|
} |
2859 |
|
|
2860 |
< |
static abstract class IntKeyWeakValueNode |
2860 |
> |
abstract static class IntKeyWeakValueNode |
2861 |
|
extends IntKeyNode { |
2862 |
|
volatile EmbeddedWeakReference valueRef; |
2863 |
|
final CustomConcurrentHashMap cchm; |
2891 |
|
super(locator, key, value, cchm); |
2892 |
|
} |
2893 |
|
public final Node getLinkage() { return null; } |
2894 |
< |
public final void setLinkage(Node r) { } |
2894 |
> |
public final void setLinkage(Node linkage) { } |
2895 |
|
} |
2896 |
|
|
2897 |
|
static final class LinkedIntKeyWeakValueNode |
2905 |
|
this.linkage = linkage; |
2906 |
|
} |
2907 |
|
public final Node getLinkage() { return linkage; } |
2908 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2908 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2909 |
|
} |
2910 |
|
|
2911 |
|
static final class IntKeyWeakValueNodeFactory |
2925 |
|
} |
2926 |
|
|
2927 |
|
|
2928 |
< |
static abstract class IntKeySoftValueNode |
2928 |
> |
abstract static class IntKeySoftValueNode |
2929 |
|
extends IntKeyNode { |
2930 |
|
volatile EmbeddedSoftReference valueRef; |
2931 |
|
final CustomConcurrentHashMap cchm; |
2959 |
|
super(locator, key, value, cchm); |
2960 |
|
} |
2961 |
|
public final Node getLinkage() { return null; } |
2962 |
< |
public final void setLinkage(Node r) { } |
2962 |
> |
public final void setLinkage(Node linkage) { } |
2963 |
|
} |
2964 |
|
|
2965 |
|
static final class LinkedIntKeySoftValueNode |
2973 |
|
this.linkage = linkage; |
2974 |
|
} |
2975 |
|
public final Node getLinkage() { return linkage; } |
2976 |
< |
public final void setLinkage(Node r) { linkage = r; } |
2976 |
> |
public final void setLinkage(Node linkage) { this.linkage = linkage; } |
2977 |
|
} |
2978 |
|
|
2979 |
|
static final class IntKeySoftValueNodeFactory |
3006 |
|
try { |
3007 |
|
UNSAFE = getUnsafe(); |
3008 |
|
tableBase = UNSAFE.arrayBaseOffset(Node[].class); |
3009 |
< |
int s = UNSAFE.arrayIndexScale(Node[].class); |
3010 |
< |
if ((s & (s-1)) != 0) |
3009 |
> |
int scale = UNSAFE.arrayIndexScale(Node[].class); |
3010 |
> |
if ((scale & (scale - 1)) != 0) |
3011 |
|
throw new Error("data type scale not a power of two"); |
3012 |
< |
tableShift = 31 - Integer.numberOfLeadingZeros(s); |
3012 |
> |
tableShift = 31 - Integer.numberOfLeadingZeros(scale); |
3013 |
|
segmentsBase = UNSAFE.arrayBaseOffset(Segment[].class); |
3014 |
< |
s = UNSAFE.arrayIndexScale(Segment[].class); |
3015 |
< |
if ((s & (s-1)) != 0) |
3014 |
> |
scale = UNSAFE.arrayIndexScale(Segment[].class); |
3015 |
> |
if ((scale & (scale - 1)) != 0) |
3016 |
|
throw new Error("data type scale not a power of two"); |
3017 |
< |
segmentsShift = 31 - Integer.numberOfLeadingZeros(s); |
3017 |
> |
segmentsShift = 31 - Integer.numberOfLeadingZeros(scale); |
3018 |
|
} catch (Throwable e) { |
3019 |
|
throw new RuntimeException("Could not initialize intrinsics", e); |
3020 |
|
} |