31 |
|
* establish a computed value, along with |
32 |
|
* <code>RemappingFunctions</code> that can be used in method |
33 |
|
* {@link CustomConcurrentHashMap#compute} to atomically |
34 |
< |
* replace values. |
34 |
> |
* replace values. |
35 |
|
* |
36 |
|
* <li>Factory methods returning specialized forms for <tt>int</tt> |
37 |
|
* keys and/or values, that may be more space-efficient |
38 |
|
* |
39 |
|
* </ul> |
40 |
< |
* |
40 |
> |
* |
41 |
|
* Per-map settings are established in constructors, as in the |
42 |
|
* following usages (that assume static imports to simplify expression |
43 |
|
* of configuration parameters): |
44 |
< |
* |
44 |
> |
* |
45 |
|
* <pre> |
46 |
|
* {@code |
47 |
|
* identityMap = new CustomConcurrentHashMap<Person,Salary> |
55 |
|
* public boolean equal(Person k, Object x) { |
56 |
|
* return x instanceOf Person && k.name.equals(((Person)x).name); |
57 |
|
* } |
58 |
< |
* public int hash(Object x) { |
58 |
> |
* public int hash(Object x) { |
59 |
|
* return (x instanceOf Person)? ((Person)x).name.hashCode() : 0; |
60 |
|
* } |
61 |
|
* }, |
69 |
|
* and identity-based equality for keys. The third usage |
70 |
|
* illustrates a map with a custom Equivalence that looks only at the |
71 |
|
* name field of a (fictional) Person class. |
72 |
< |
* |
72 |
> |
* |
73 |
|
* <p>This class also includes nested class {@link KeySet} |
74 |
|
* that provides space-efficient Set views of maps, also supporting |
75 |
|
* method <code>intern</code>, which may be of use in canonicalizing |
81 |
|
* via a background thread common across all maps. Because of the |
82 |
|
* potential for asynchronous clearing of References, methods such as |
83 |
|
* <code>containsValue</code> have weaker guarantees than you might |
84 |
< |
* expect even in the absence of other explicity concurrent |
84 |
> |
* expect even in the absence of other explicitly concurrent |
85 |
|
* operations. For example <code>containsValue(value)</code> may |
86 |
|
* return true even if <code>value</code> is no longer available upon |
87 |
|
* return from the method. |
126 |
|
* Additionally, because Reference keys/values may become null |
127 |
|
* asynchronously, we cannot ensure snapshot integrity in methods |
128 |
|
* such as containsValue, so do not try to obtain them (so, no |
129 |
< |
* modCounts etc). |
129 |
> |
* modCounts etc). |
130 |
|
* |
131 |
|
* Also, the volatility of Segment count vs table fields are |
132 |
|
* swapped, enabled by ensuring fences on new node assignments. |
138 |
|
* maps. strong denotes ordinary objects. weak and soft denote the |
139 |
|
* corresponding {@link java.lang.ref.Reference} types. |
140 |
|
*/ |
141 |
< |
public enum Strength { |
141 |
> |
public enum Strength { |
142 |
|
strong("Strong"), weak("Weak"), soft("Soft"); |
143 |
|
private final String name; |
144 |
|
Strength(String name) { this.name = name; } |
145 |
|
String getName() { return name; } |
146 |
|
}; |
147 |
|
|
148 |
< |
|
148 |
> |
|
149 |
|
/** The strength of ordinary references */ |
150 |
|
public static final Strength STRONG = Strength.strong; |
151 |
|
|
184 |
|
*/ |
185 |
|
boolean equal(K key, Object x); |
186 |
|
/** |
187 |
< |
* Returns a hash value such that equal(a, b) implies |
187 |
> |
* Returns a hash value such that equal(a, b) implies |
188 |
|
* hash(a)==hash(b). |
189 |
|
* @param x an object queried for membership |
190 |
|
* @return a hash value |
194 |
|
|
195 |
|
// builtin equivalences |
196 |
|
|
197 |
< |
static final class EquivalenceUsingIdentity |
197 |
> |
static final class EquivalenceUsingIdentity |
198 |
|
implements Equivalence<Object>, Serializable { |
199 |
|
private static final long serialVersionUID = 7259069246764182397L; |
200 |
|
public final boolean equal(Object a, Object b) { return a == b; } |
201 |
|
public final int hash(Object a) { return System.identityHashCode(a); } |
202 |
|
} |
203 |
|
|
204 |
< |
static final class EquivalenceUsingEquals |
204 |
> |
static final class EquivalenceUsingEquals |
205 |
|
implements Equivalence<Object>, Serializable { |
206 |
|
private static final long serialVersionUID = 7259069247764182397L; |
207 |
|
public final boolean equal(Object a, Object b) { return a.equals(b); } |
212 |
|
* An Equivalence object performing identity-based comparisons |
213 |
|
* and using {@link System#identityHashCode} for hashing |
214 |
|
*/ |
215 |
< |
public static final Equivalence<Object> IDENTITY = |
215 |
> |
public static final Equivalence<Object> IDENTITY = |
216 |
|
new EquivalenceUsingIdentity(); |
217 |
< |
|
217 |
> |
|
218 |
|
/** |
219 |
|
* An Equivalence object performing {@link Object#equals} based comparisons |
220 |
|
* and using {@link Object#hashCode} hashing |
221 |
|
*/ |
222 |
< |
public static final Equivalence<Object> EQUALS = |
222 |
> |
public static final Equivalence<Object> EQUALS = |
223 |
|
new EquivalenceUsingEquals(); |
224 |
|
|
225 |
|
/** |
226 |
|
* A function computing a mapping from the given key to a value, |
227 |
< |
* or <code>null</code> if there is no mapping. |
227 |
> |
* or <code>null</code> if there is no mapping. |
228 |
|
*/ |
229 |
|
public static interface MappingFunction<K, V> { |
230 |
|
/** |
275 |
|
*/ |
276 |
|
static interface NodeFactory extends Serializable { |
277 |
|
/** |
278 |
< |
* Creates and returns a Node using the given parameters |
278 |
> |
* Creates and returns a Node using the given parameters. |
279 |
> |
* |
280 |
|
* @param locator an opaque immutable locator for this node |
281 |
< |
* @parem key the (nonnull) immutable key |
282 |
< |
* @parem value the (nonnull) volatile value; |
283 |
< |
* @param cchm the table creating this node. |
281 |
> |
* @param key the (non-null) immutable key |
282 |
> |
* @param value the (non-null) volatile value |
283 |
> |
* @param cchm the table creating this node |
284 |
|
* @param linkage an opaque volatile linkage for maintaining this node |
285 |
|
*/ |
286 |
< |
Node newNode(int locator, Object key, Object value, |
286 |
> |
Node newNode(int locator, Object key, Object value, |
287 |
|
CustomConcurrentHashMap cchm, Node linkage); |
288 |
|
} |
289 |
|
|
304 |
|
static interface Node extends Reclaimable { |
305 |
|
/** |
306 |
|
* Returns the key established during the creation of this node. |
307 |
< |
* Note: This method is named "get" rether than "getKey" |
307 |
> |
* Note: This method is named "get" rather than "getKey" |
308 |
|
* to simplify usage of Reference keys. |
309 |
|
* @return the key |
310 |
|
*/ |
333 |
|
void setValue(Object value); |
334 |
|
|
335 |
|
/** |
336 |
< |
* Returns the lonkage established during the creation of this |
336 |
> |
* Returns the linkage established during the creation of this |
337 |
|
* node or, if since updated, the linkage set by the most |
338 |
|
* recent call to setLinkage. |
339 |
|
* @return the linkage |
356 |
|
static final class Segment extends ReentrantLock { |
357 |
|
volatile Node[] table; |
358 |
|
int count; |
359 |
< |
|
359 |
> |
|
360 |
|
final void decrementCount() { |
361 |
|
if (--count == 0) |
362 |
|
table = null; |
397 |
|
int oldCapacity = oldTable.length; |
398 |
|
if (oldCapacity >= MAX_SEGMENT_CAPACITY) |
399 |
|
return oldTable; |
400 |
< |
Node[] newTable = |
400 |
> |
Node[] newTable = |
401 |
|
(Node[])new Node[oldCapacity<<1]; |
402 |
|
int sizeMask = newTable.length - 1; |
403 |
|
NodeFactory fac = cchm.factory; |
437 |
|
(pv = p.getValue()) == null) |
438 |
|
--count; |
439 |
|
else |
440 |
< |
newTable[k] = |
440 |
> |
newTable[k] = |
441 |
|
fac.newNode(ph, pk, pv, cchm, newTable[k]); |
442 |
|
} |
443 |
|
} |
478 |
|
* The segments, each of which acts as a hash table |
479 |
|
*/ |
480 |
|
transient volatile Segment[] segments; |
481 |
< |
|
481 |
> |
|
482 |
|
/** |
483 |
|
* The factory for this map |
484 |
|
*/ |
485 |
|
final NodeFactory factory; |
486 |
< |
|
486 |
> |
|
487 |
|
/** |
488 |
|
* Equivalence object for keys |
489 |
|
*/ |
490 |
|
final Equivalence<? super K> keyEquivalence; |
491 |
< |
|
491 |
> |
|
492 |
|
/** |
493 |
|
* Equivalence object for values |
494 |
|
*/ |
495 |
|
final Equivalence<? super V> valueEquivalence; |
496 |
< |
|
496 |
> |
|
497 |
|
/** |
498 |
|
* The initial size of Segment tables when they are first constructed |
499 |
|
*/ |
516 |
|
this.keyEquivalence = keq; |
517 |
|
this.valueEquivalence = veq; |
518 |
|
// Reflectively assemble factory name |
519 |
< |
String factoryName = |
520 |
< |
CustomConcurrentHashMap.class.getName() + "$" + |
521 |
< |
ks + "Key" + |
519 |
> |
String factoryName = |
520 |
> |
CustomConcurrentHashMap.class.getName() + "$" + |
521 |
> |
ks + "Key" + |
522 |
|
vs + "ValueNodeFactory"; |
523 |
|
try { |
524 |
|
this.factory = (NodeFactory) |
533 |
|
int sc = (int)((1L + (4L * es) / 3) >>> SEGMENT_BITS); |
534 |
|
if (sc < MIN_SEGMENT_CAPACITY) |
535 |
|
sc = MIN_SEGMENT_CAPACITY; |
536 |
< |
else if (sc > MAX_SEGMENT_CAPACITY) |
537 |
< |
sc = MAX_SEGMENT_CAPACITY; |
538 |
< |
this.initialSegmentCapacity = sc; |
536 |
> |
int capacity = MIN_SEGMENT_CAPACITY; // ensure power of two |
537 |
> |
while (capacity < sc) |
538 |
> |
capacity <<= 1; |
539 |
> |
if (capacity > MAX_SEGMENT_CAPACITY) |
540 |
> |
capacity = MAX_SEGMENT_CAPACITY; |
541 |
> |
this.initialSegmentCapacity = capacity; |
542 |
|
} |
543 |
|
this.segments = (Segment[])new Segment[NSEGMENTS]; |
544 |
|
} |
558 |
|
Strength valueStrength, |
559 |
|
Equivalence<? super V> valueEquivalence, |
560 |
|
int expectedSize) { |
561 |
< |
this(keyStrength.getName(), keyEquivalence, |
561 |
> |
this(keyStrength.getName(), keyEquivalence, |
562 |
|
valueStrength.getName(), valueEquivalence, |
563 |
|
expectedSize); |
564 |
|
} |
604 |
|
Equivalence<? super KeyType> keyEquivalence, |
605 |
|
int expectedSize) { |
606 |
|
return new CustomConcurrentHashMap<KeyType, Integer> |
607 |
< |
(keyStrength.getName(), keyEquivalence, INT_STRING, EQUALS, |
607 |
> |
(keyStrength.getName(), keyEquivalence, INT_STRING, EQUALS, |
608 |
|
expectedSize); |
609 |
|
} |
610 |
|
|
618 |
|
public static CustomConcurrentHashMap<Integer, Integer> |
619 |
|
newIntKeyIntValueMap(int expectedSize) { |
620 |
|
return new CustomConcurrentHashMap<Integer, Integer> |
621 |
< |
(INT_STRING, EQUALS, INT_STRING, EQUALS, |
621 |
> |
(INT_STRING, EQUALS, INT_STRING, EQUALS, |
622 |
|
expectedSize); |
623 |
|
} |
624 |
|
|
633 |
|
|
634 |
|
/** |
635 |
|
* Returns the segment for possibly inserting into the table |
636 |
< |
* associated with given hash, constructing it if necesary. |
636 |
> |
* associated with given hash, constructing it if necessary. |
637 |
|
* @param hash the hash code for the key |
638 |
|
* @return the segment |
639 |
|
*/ |
666 |
|
while (p != null) { |
667 |
|
Object k = p.get(); |
668 |
|
if (k == key || |
669 |
< |
(k != null && |
670 |
< |
p.getLocator() == hash && |
669 |
> |
(k != null && |
670 |
> |
p.getLocator() == hash && |
671 |
|
keyEquivalence.equal((K)k, key))) |
672 |
|
return p; |
673 |
|
p = p.getLinkage(); |
700 |
|
* if no such mapping exists |
701 |
|
* |
702 |
|
* @param key possible key |
703 |
< |
* @return the value associated with the kew or <tt>null</tt> if |
703 |
> |
* @return the value associated with the key or <tt>null</tt> if |
704 |
|
* there is no mapping. |
705 |
|
* @throws NullPointerException if the specified key is null |
706 |
|
*/ |
716 |
|
} |
717 |
|
|
718 |
|
/** |
719 |
< |
* Share dimplementation for put, putIfAbsent |
719 |
> |
* Shared implementation for put, putIfAbsent |
720 |
|
*/ |
721 |
|
final V doPut(K key, V value, boolean onlyIfNull) { |
722 |
|
if (key == null || value == null) |
828 |
|
Node r = findNode(key, hash, seg); |
829 |
|
if (r != null) { |
830 |
|
V v = (V)(r.getValue()); |
831 |
< |
if (v == oldValue || |
831 |
> |
if (v == oldValue || |
832 |
|
(v != null && valueEquivalence.equal(v, oldValue))) { |
833 |
|
r.setValue(newValue); |
834 |
|
replaced = true; |
868 |
|
Object k = p.get(); |
869 |
|
if (k == key || |
870 |
|
(k != null && |
871 |
< |
p.getLocator() == hash && |
871 |
> |
p.getLocator() == hash && |
872 |
|
keyEquivalence.equal((K)k, key))) { |
873 |
|
oldValue = (V)(p.getValue()); |
874 |
|
if (pred == null) |
875 |
< |
tab[i] = n; |
875 |
> |
tab[i] = n; |
876 |
|
else |
877 |
|
pred.setLinkage(n); |
878 |
|
seg.decrementCount(); |
915 |
|
Object k = p.get(); |
916 |
|
if (k == key || |
917 |
|
(k != null && |
918 |
< |
p.getLocator() == hash && |
918 |
> |
p.getLocator() == hash && |
919 |
|
keyEquivalence.equal((K)k, key))) { |
920 |
|
V v = (V)(p.getValue()); |
921 |
|
if (v == value || |
922 |
< |
(v != null && |
922 |
> |
(v != null && |
923 |
|
valueEquivalence.equal(v, value))) { |
924 |
|
if (pred == null) |
925 |
< |
tab[i] = n; |
925 |
> |
tab[i] = n; |
926 |
|
else |
927 |
|
pred.setLinkage(n); |
928 |
|
seg.decrementCount(); |
959 |
|
while (p != null) { |
960 |
|
Node n = p.getLinkage(); |
961 |
|
if (p.get() != null && p.getValue() != null) { |
962 |
+ |
pred = p; |
963 |
+ |
p = n; |
964 |
+ |
} |
965 |
+ |
else { |
966 |
|
if (pred == null) |
967 |
< |
tab[i] = n; |
967 |
> |
tab[i] = n; |
968 |
|
else |
969 |
|
pred.setLinkage(n); |
970 |
|
seg.decrementCount(); |
971 |
|
p = n; |
972 |
|
} |
965 |
– |
else { |
966 |
– |
pred = p; |
967 |
– |
p = n; |
968 |
– |
} |
973 |
|
} |
974 |
|
} |
975 |
|
} finally { |
987 |
|
final Segment[] segs = this.segments; |
988 |
|
for (int i = 0; i < segs.length; ++i) { |
989 |
|
Segment seg = segs[i]; |
990 |
< |
if (seg != null && |
991 |
< |
seg.getTableForTraversal() != null && |
990 |
> |
if (seg != null && |
991 |
> |
seg.getTableForTraversal() != null && |
992 |
|
seg.count != 0) |
993 |
|
return false; |
994 |
|
} |
1034 |
|
Node[] tab; |
1035 |
|
if (seg != null && (tab = seg.getTableForTraversal()) != null) { |
1036 |
|
for (int j = 0; j < tab.length; ++j) { |
1037 |
< |
for (Node p = tab[j]; |
1038 |
< |
p != null; |
1037 |
> |
for (Node p = tab[j]; |
1038 |
> |
p != null; |
1039 |
|
p = p.getLinkage()) { |
1040 |
|
V v = (V)(p.getValue()); |
1041 |
|
if (v == value || |
1082 |
|
* </pre> |
1083 |
|
* |
1084 |
|
* except that the action is performed atomically. Some |
1085 |
< |
* attemmpted operations on this map by other threads may be |
1085 |
> |
* attempted operations on this map by other threads may be |
1086 |
|
* blocked while computation is in progress. Because this function |
1087 |
|
* is invoked within atomicity control, the computation should be |
1088 |
|
* short and simple. The most common usage is to construct a new |
1090 |
|
* |
1091 |
|
* @param key key with which the specified value is to be associated |
1092 |
|
* @param mappingFunction the function to compute a value |
1093 |
< |
* @return the current (existing or computed) value associated with |
1093 |
> |
* @return the current (existing or computed) value associated with |
1094 |
|
* the specified key, or <tt>null</tt> if the computation |
1095 |
|
* returned <tt>null</tt>. |
1096 |
< |
* @throws NullPointerException if the specified key or mappingFunction |
1096 |
> |
* @throws NullPointerException if the specified key or mappingFunction |
1097 |
|
* is null, |
1098 |
|
* @throws RuntimeException or Error if the mappingFunction does so, |
1099 |
|
* in which case the mapping is left unestablished. |
1115 |
|
// Map is OK if function throws exception |
1116 |
|
v = mappingFunction.map(key); |
1117 |
|
if (v != null) { |
1118 |
< |
if (r != null) |
1118 |
> |
if (r != null) |
1119 |
|
r.setValue(v); |
1120 |
|
else { |
1121 |
|
Node[] tab = seg.getTableForAdd(this); |
1148 |
|
* else |
1149 |
|
* return remove(key); |
1150 |
|
* </pre> |
1151 |
< |
* |
1152 |
< |
* except that the action is performed atomically. Some attemmpted |
1151 |
> |
* |
1152 |
> |
* except that the action is performed atomically. Some attempted |
1153 |
|
* operations on this map by other threads may be blocked while |
1154 |
|
* computation is in progress. |
1155 |
|
* |
1165 |
|
* @param key key with which the specified value is to be associated |
1166 |
|
* @param remappingFunction the function to compute a value |
1167 |
|
* @return the updated value or |
1168 |
< |
* <tt>null</tt> if the computation returned <tt>null</tt> |
1169 |
< |
* @throws NullPointerException if the specified key or remappingFunction |
1168 |
> |
* <tt>null</tt> if the computation returned <tt>null</tt> |
1169 |
> |
* @throws NullPointerException if the specified key or remappingFunction |
1170 |
|
* is null, |
1171 |
|
* @throws RuntimeException or Error if the remappingFunction does so, |
1172 |
|
* in which case the mapping is left in its previous state |
1187 |
|
K k = (K)(p.get()); |
1188 |
|
if (k == key || |
1189 |
|
(k != null && |
1190 |
< |
p.getLocator() == hash && |
1190 |
> |
p.getLocator() == hash && |
1191 |
|
keyEquivalence.equal(k, key))) { |
1192 |
|
value = (V)(p.getValue()); |
1193 |
|
break; |
1197 |
|
} |
1198 |
|
value = remappingFunction.remap(key, value); |
1199 |
|
if (p != null) { |
1200 |
< |
if (value != null) |
1200 |
> |
if (value != null) |
1201 |
|
p.setValue(value); |
1202 |
|
else { |
1203 |
|
Node n = p.getLinkage(); |
1204 |
|
if (pred == null) |
1205 |
< |
tab[i] = n; |
1205 |
> |
tab[i] = n; |
1206 |
|
else |
1207 |
|
pred.setLinkage(n); |
1208 |
|
seg.decrementCount(); |
1209 |
|
} |
1210 |
|
} |
1211 |
|
else if (value != null) { |
1212 |
< |
Node r = |
1212 |
> |
Node r = |
1213 |
|
factory.newNode(hash, key, value, this, tab[i]); |
1214 |
|
// Fences.preStoreFence(r); |
1215 |
|
// tab[i] = r; |
1258 |
|
else if (nextSegmentIndex >= 0) { |
1259 |
|
Segment seg = segments[nextSegmentIndex--]; |
1260 |
|
Node[] t; |
1261 |
< |
if (seg != null && |
1261 |
> |
if (seg != null && |
1262 |
|
(t = seg.getTableForTraversal()) != null) { |
1263 |
|
currentTable = t; |
1264 |
|
nextTableIndex = t.length - 1; |
1291 |
|
final Map.Entry<K,V> nextEntry() { |
1292 |
|
if (nextNode == null) |
1293 |
|
throw new NoSuchElementException(); |
1294 |
< |
WriteThroughEntry e = new WriteThroughEntry((K)nextKey, |
1294 |
> |
WriteThroughEntry e = new WriteThroughEntry((K)nextKey, |
1295 |
|
(V)nextValue); |
1296 |
|
advance(); |
1297 |
|
return e; |
1334 |
|
} |
1335 |
|
} |
1336 |
|
|
1337 |
< |
final class KeyIterator extends HashIterator |
1337 |
> |
final class KeyIterator extends HashIterator |
1338 |
|
implements Iterator<K> { |
1339 |
< |
public K next() { |
1340 |
< |
return super.nextKey(); |
1339 |
> |
public K next() { |
1340 |
> |
return super.nextKey(); |
1341 |
|
} |
1342 |
|
} |
1343 |
|
|
1345 |
|
return new KeyIterator(); |
1346 |
|
} |
1347 |
|
|
1348 |
< |
final class ValueIterator extends HashIterator |
1348 |
> |
final class ValueIterator extends HashIterator |
1349 |
|
implements Iterator<V> { |
1350 |
< |
public V next() { |
1351 |
< |
return super.nextValue(); |
1350 |
> |
public V next() { |
1351 |
> |
return super.nextValue(); |
1352 |
|
} |
1353 |
|
} |
1354 |
|
|
1355 |
< |
final class EntryIterator extends HashIterator |
1355 |
> |
final class EntryIterator extends HashIterator |
1356 |
|
implements Iterator<Map.Entry<K,V>> { |
1357 |
|
public Map.Entry<K,V> next() { |
1358 |
|
return super.nextEntry(); |
1407 |
|
return false; |
1408 |
|
Map.Entry<?,?> e = (Map.Entry<?,?>)o; |
1409 |
|
V v = CustomConcurrentHashMap.this.get(e.getKey()); |
1410 |
< |
return v != null && |
1410 |
> |
return v != null && |
1411 |
|
valueEquivalence.equal(v, e.getValue()); |
1412 |
|
} |
1413 |
|
public boolean remove(Object o) { |
1505 |
|
public boolean equals(Object o) { |
1506 |
|
if (o == this) |
1507 |
|
return true; |
1508 |
< |
|
1508 |
> |
|
1509 |
|
if (!(o instanceof Map)) |
1510 |
|
return false; |
1511 |
|
Map<K,V> m = (Map<K,V>) o; |
1606 |
|
* that will be held in the set. If no estimate is known, zero |
1607 |
|
* is an acceptable value. |
1608 |
|
*/ |
1609 |
< |
public KeySet(Strength strength, |
1609 |
> |
public KeySet(Strength strength, |
1610 |
|
Equivalence<? super K> equivalence, |
1611 |
|
int expectedSize) { |
1612 |
|
this.cchm = new CustomConcurrentHashMap<K,K> |
1613 |
< |
(strength.getName(), equivalence, |
1613 |
> |
(strength.getName(), equivalence, |
1614 |
|
SELF_STRING, equivalence, expectedSize); |
1615 |
|
} |
1616 |
|
|
1618 |
|
* Returns an element equivalent to the given element with |
1619 |
|
* respect to this set's Equivalence, if such an element |
1620 |
|
* exists, else adds and returns the given element. |
1621 |
< |
* |
1621 |
> |
* |
1622 |
|
* @param e the element |
1623 |
|
* @return e, or an element equivalent to e. |
1624 |
|
*/ |
1625 |
|
public K intern(K e) { |
1626 |
< |
return cchm.doPut(e, e, true); |
1626 |
> |
K oldElement = cchm.doPut(e, e, true); |
1627 |
> |
return (oldElement != null) ? oldElement : e; |
1628 |
|
} |
1629 |
< |
|
1629 |
> |
|
1630 |
|
/** |
1631 |
|
* Returns <tt>true</tt> if this set contains an |
1632 |
|
* element equivalent to the given element with respect |
1637 |
|
public boolean contains(Object o) { |
1638 |
|
return cchm.containsKey(o); |
1639 |
|
} |
1640 |
< |
|
1640 |
> |
|
1641 |
|
/** |
1642 |
|
* Returns a <i>weakly consistent iterator</i> over the |
1643 |
|
* elements in this set, that may reflect some, all or none of |
1648 |
|
public Iterator<K> iterator() { |
1649 |
|
return cchm.keyIterator(); |
1650 |
|
} |
1651 |
< |
|
1651 |
> |
|
1652 |
|
/** |
1653 |
|
* Adds the specified element to this set if there is not |
1654 |
|
* already an element equivalent to the given element with |
1690 |
|
public int size() { |
1691 |
|
return cchm.size(); |
1692 |
|
} |
1693 |
< |
|
1693 |
> |
|
1694 |
|
/** |
1695 |
|
* Removes all of the elements from this set. |
1696 |
|
*/ |
1753 |
|
Reference<?> r = q.remove(); |
1754 |
|
if (r instanceof Reclaimable) |
1755 |
|
((Reclaimable)r).onReclamation(); |
1756 |
< |
} catch (InterruptedException e) { |
1757 |
< |
/* ignore */ |
1756 |
> |
} catch (InterruptedException e) { |
1757 |
> |
/* ignore */ |
1758 |
|
} |
1759 |
|
} |
1760 |
|
} |
1762 |
|
|
1763 |
|
// classes extending Weak/soft refs embedded in reclaimable nodes |
1764 |
|
|
1765 |
< |
static class EmbeddedWeakReference extends WeakReference |
1765 |
> |
static class EmbeddedWeakReference extends WeakReference |
1766 |
|
implements Reclaimable { |
1767 |
|
final Reclaimable outer; |
1768 |
|
EmbeddedWeakReference(Object x, Reclaimable outer) { |
1769 |
|
super(x, getReclamationQueue()); |
1770 |
|
this.outer = outer; |
1771 |
|
} |
1772 |
< |
public final void onReclamation() { |
1772 |
> |
public final void onReclamation() { |
1773 |
|
clear(); |
1774 |
< |
outer.onReclamation(); |
1774 |
> |
outer.onReclamation(); |
1775 |
|
} |
1776 |
|
} |
1777 |
|
|
1778 |
< |
static class EmbeddedSoftReference extends SoftReference |
1778 |
> |
static class EmbeddedSoftReference extends SoftReference |
1779 |
|
implements Reclaimable { |
1780 |
|
final Reclaimable outer; |
1781 |
|
EmbeddedSoftReference(Object x, Reclaimable outer) { |
1782 |
|
super(x, getReclamationQueue()); |
1783 |
|
this.outer = outer; |
1784 |
|
} |
1785 |
< |
public final void onReclamation() { |
1785 |
> |
public final void onReclamation() { |
1786 |
|
clear(); |
1787 |
< |
outer.onReclamation(); |
1787 |
> |
outer.onReclamation(); |
1788 |
|
} |
1789 |
|
} |
1790 |
|
|
1804 |
|
} |
1805 |
|
|
1806 |
|
|
1807 |
< |
static abstract class StrongKeySelfValueNode |
1807 |
> |
static abstract class StrongKeySelfValueNode |
1808 |
|
extends StrongKeyNode { |
1809 |
|
StrongKeySelfValueNode(int locator, Object key) { |
1810 |
|
super(locator, key); |
1814 |
|
public final void onReclamation() { } |
1815 |
|
} |
1816 |
|
|
1817 |
< |
static final class TerminalStrongKeySelfValueNode |
1817 |
> |
static final class TerminalStrongKeySelfValueNode |
1818 |
|
extends StrongKeySelfValueNode { |
1819 |
|
TerminalStrongKeySelfValueNode(int locator, Object key) { |
1820 |
|
super(locator, key); |
1823 |
|
public final void setLinkage(Node r) { } |
1824 |
|
} |
1825 |
|
|
1826 |
< |
static final class LinkedStrongKeySelfValueNode |
1826 |
> |
static final class LinkedStrongKeySelfValueNode |
1827 |
|
extends StrongKeySelfValueNode { |
1828 |
|
volatile Node linkage; |
1829 |
< |
LinkedStrongKeySelfValueNode(int locator, Object key, |
1829 |
> |
LinkedStrongKeySelfValueNode(int locator, Object key, |
1830 |
|
Node linkage) { |
1831 |
|
super(locator, key); |
1832 |
|
this.linkage = linkage; |
1839 |
|
implements NodeFactory, Serializable { |
1840 |
|
private static final long serialVersionUID = 7249069346764182397L; |
1841 |
|
public final Node newNode(int locator, |
1842 |
< |
Object key, Object value, |
1842 |
> |
Object key, Object value, |
1843 |
|
CustomConcurrentHashMap cchm, |
1844 |
|
Node linkage) { |
1845 |
|
if (linkage == null) |
1849 |
|
return new LinkedStrongKeySelfValueNode |
1850 |
|
(locator, key, linkage); |
1851 |
|
} |
1852 |
< |
} |
1852 |
> |
} |
1853 |
|
|
1854 |
< |
static abstract class StrongKeyStrongValueNode |
1854 |
> |
static abstract class StrongKeyStrongValueNode |
1855 |
|
extends StrongKeyNode { |
1856 |
|
volatile Object value; |
1857 |
|
StrongKeyStrongValueNode(int locator, Object key, Object value) { |
1863 |
|
public final void onReclamation() { } |
1864 |
|
} |
1865 |
|
|
1866 |
< |
static final class TerminalStrongKeyStrongValueNode |
1866 |
> |
static final class TerminalStrongKeyStrongValueNode |
1867 |
|
extends StrongKeyStrongValueNode { |
1868 |
|
TerminalStrongKeyStrongValueNode(int locator, |
1869 |
|
Object key, Object value) { |
1873 |
|
public final void setLinkage(Node r) { } |
1874 |
|
} |
1875 |
|
|
1876 |
< |
static final class LinkedStrongKeyStrongValueNode |
1876 |
> |
static final class LinkedStrongKeyStrongValueNode |
1877 |
|
extends StrongKeyStrongValueNode { |
1878 |
|
volatile Node linkage; |
1879 |
|
LinkedStrongKeyStrongValueNode(int locator, |
1880 |
< |
Object key, Object value, |
1880 |
> |
Object key, Object value, |
1881 |
|
Node linkage) { |
1882 |
|
super(locator, key, value); |
1883 |
|
this.linkage = linkage; |
1886 |
|
public final void setLinkage(Node r) { linkage = r; } |
1887 |
|
} |
1888 |
|
|
1889 |
< |
static final class StrongKeyStrongValueNodeFactory |
1889 |
> |
static final class StrongKeyStrongValueNodeFactory |
1890 |
|
implements NodeFactory, Serializable { |
1891 |
|
private static final long serialVersionUID = 7249069346764182397L; |
1892 |
|
public final Node newNode(int locator, |
1893 |
< |
Object key, Object value, |
1893 |
> |
Object key, Object value, |
1894 |
|
CustomConcurrentHashMap cchm, |
1895 |
|
Node linkage) { |
1896 |
|
if (linkage == null) |
1900 |
|
return new LinkedStrongKeyStrongValueNode |
1901 |
|
(locator, key, value, linkage); |
1902 |
|
} |
1903 |
< |
} |
1903 |
> |
} |
1904 |
|
|
1905 |
|
// ... |
1906 |
|
|
1907 |
< |
static abstract class StrongKeyIntValueNode |
1907 |
> |
static abstract class StrongKeyIntValueNode |
1908 |
|
extends StrongKeyNode { |
1909 |
|
volatile int value; |
1910 |
|
StrongKeyIntValueNode(int locator, Object key, Object value) { |
1912 |
|
this.value = ((Integer)value).intValue(); |
1913 |
|
} |
1914 |
|
public final Object getValue() { return Integer.valueOf(value); } |
1915 |
< |
public final void setValue(Object value) { |
1915 |
> |
public final void setValue(Object value) { |
1916 |
|
this.value = ((Integer)value).intValue(); |
1917 |
|
} |
1918 |
|
public final void onReclamation() { } |
1919 |
|
} |
1920 |
|
|
1921 |
< |
static final class TerminalStrongKeyIntValueNode |
1921 |
> |
static final class TerminalStrongKeyIntValueNode |
1922 |
|
extends StrongKeyIntValueNode { |
1923 |
|
TerminalStrongKeyIntValueNode(int locator, |
1924 |
|
Object key, Object value) { |
1928 |
|
public final void setLinkage(Node r) { } |
1929 |
|
} |
1930 |
|
|
1931 |
< |
static final class LinkedStrongKeyIntValueNode |
1931 |
> |
static final class LinkedStrongKeyIntValueNode |
1932 |
|
extends StrongKeyIntValueNode { |
1933 |
|
volatile Node linkage; |
1934 |
|
LinkedStrongKeyIntValueNode(int locator, |
1935 |
< |
Object key, Object value, |
1935 |
> |
Object key, Object value, |
1936 |
|
Node linkage) { |
1937 |
|
super(locator, key, value); |
1938 |
|
this.linkage = linkage; |
1941 |
|
public final void setLinkage(Node r) { linkage = r; } |
1942 |
|
} |
1943 |
|
|
1944 |
< |
static final class StrongKeyIntValueNodeFactory |
1944 |
> |
static final class StrongKeyIntValueNodeFactory |
1945 |
|
implements NodeFactory, Serializable { |
1946 |
|
private static final long serialVersionUID = 7249069346764182397L; |
1947 |
|
public final Node newNode(int locator, |
1948 |
< |
Object key, Object value, |
1948 |
> |
Object key, Object value, |
1949 |
|
CustomConcurrentHashMap cchm, |
1950 |
|
Node linkage) { |
1951 |
|
if (linkage == null) |
1955 |
|
return new LinkedStrongKeyIntValueNode |
1956 |
|
(locator, key, value, linkage); |
1957 |
|
} |
1958 |
< |
} |
1958 |
> |
} |
1959 |
|
|
1960 |
|
// ... |
1961 |
|
|
1962 |
< |
static abstract class StrongKeyWeakValueNode |
1962 |
> |
static abstract class StrongKeyWeakValueNode |
1963 |
|
extends StrongKeyNode { |
1964 |
|
volatile EmbeddedWeakReference valueRef; |
1965 |
|
final CustomConcurrentHashMap cchm; |
1966 |
< |
StrongKeyWeakValueNode(int locator, Object key, Object value, |
1966 |
> |
StrongKeyWeakValueNode(int locator, Object key, Object value, |
1967 |
|
CustomConcurrentHashMap cchm) { |
1968 |
|
super(locator, key); |
1969 |
|
this.cchm = cchm; |
1985 |
|
} |
1986 |
|
} |
1987 |
|
|
1988 |
< |
static final class TerminalStrongKeyWeakValueNode |
1988 |
> |
static final class TerminalStrongKeyWeakValueNode |
1989 |
|
extends StrongKeyWeakValueNode { |
1990 |
|
TerminalStrongKeyWeakValueNode(int locator, |
1991 |
< |
Object key, Object value, |
1991 |
> |
Object key, Object value, |
1992 |
|
CustomConcurrentHashMap cchm) { |
1993 |
|
super(locator, key, value, cchm); |
1994 |
|
} |
1996 |
|
public final void setLinkage(Node r) { } |
1997 |
|
} |
1998 |
|
|
1999 |
< |
static final class LinkedStrongKeyWeakValueNode |
1999 |
> |
static final class LinkedStrongKeyWeakValueNode |
2000 |
|
extends StrongKeyWeakValueNode { |
2001 |
|
volatile Node linkage; |
2002 |
|
LinkedStrongKeyWeakValueNode(int locator, |
2003 |
< |
Object key, Object value, |
2003 |
> |
Object key, Object value, |
2004 |
|
CustomConcurrentHashMap cchm, |
2005 |
|
Node linkage) { |
2006 |
|
super(locator, key, value, cchm); |
2010 |
|
public final void setLinkage(Node r) { linkage = r; } |
2011 |
|
} |
2012 |
|
|
2013 |
< |
static final class StrongKeyWeakValueNodeFactory |
2013 |
> |
static final class StrongKeyWeakValueNodeFactory |
2014 |
|
implements NodeFactory, Serializable { |
2015 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2016 |
< |
public final Node newNode(int locator, |
2017 |
< |
Object key, Object value, |
2016 |
> |
public final Node newNode(int locator, |
2017 |
> |
Object key, Object value, |
2018 |
|
CustomConcurrentHashMap cchm, |
2019 |
|
Node linkage) { |
2020 |
|
if (linkage == null) |
2024 |
|
return new LinkedStrongKeyWeakValueNode |
2025 |
|
(locator, key, value, cchm, linkage); |
2026 |
|
} |
2027 |
< |
} |
2027 |
> |
} |
2028 |
|
|
2029 |
|
|
2030 |
< |
static abstract class StrongKeySoftValueNode |
2030 |
> |
static abstract class StrongKeySoftValueNode |
2031 |
|
extends StrongKeyNode { |
2032 |
|
volatile EmbeddedSoftReference valueRef; |
2033 |
|
final CustomConcurrentHashMap cchm; |
2034 |
< |
StrongKeySoftValueNode(int locator, Object key, Object value, |
2034 |
> |
StrongKeySoftValueNode(int locator, Object key, Object value, |
2035 |
|
CustomConcurrentHashMap cchm) { |
2036 |
|
super(locator, key); |
2037 |
|
this.cchm = cchm; |
2053 |
|
} |
2054 |
|
} |
2055 |
|
|
2056 |
< |
static final class TerminalStrongKeySoftValueNode |
2056 |
> |
static final class TerminalStrongKeySoftValueNode |
2057 |
|
extends StrongKeySoftValueNode { |
2058 |
|
TerminalStrongKeySoftValueNode(int locator, |
2059 |
< |
Object key, Object value, |
2059 |
> |
Object key, Object value, |
2060 |
|
CustomConcurrentHashMap cchm) { |
2061 |
|
super(locator, key, value, cchm); |
2062 |
|
} |
2064 |
|
public final void setLinkage(Node r) { } |
2065 |
|
} |
2066 |
|
|
2067 |
< |
static final class LinkedStrongKeySoftValueNode |
2067 |
> |
static final class LinkedStrongKeySoftValueNode |
2068 |
|
extends StrongKeySoftValueNode { |
2069 |
|
volatile Node linkage; |
2070 |
|
LinkedStrongKeySoftValueNode(int locator, |
2071 |
< |
Object key, Object value, |
2071 |
> |
Object key, Object value, |
2072 |
|
CustomConcurrentHashMap cchm, |
2073 |
|
Node linkage) { |
2074 |
|
super(locator, key, value, cchm); |
2078 |
|
public final void setLinkage(Node r) { linkage = r; } |
2079 |
|
} |
2080 |
|
|
2081 |
< |
static final class StrongKeySoftValueNodeFactory |
2081 |
> |
static final class StrongKeySoftValueNodeFactory |
2082 |
|
implements NodeFactory, Serializable { |
2083 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2084 |
< |
public final Node newNode(int locator, |
2085 |
< |
Object key, Object value, |
2084 |
> |
public final Node newNode(int locator, |
2085 |
> |
Object key, Object value, |
2086 |
|
CustomConcurrentHashMap cchm, |
2087 |
|
Node linkage) { |
2088 |
|
if (linkage == null) |
2092 |
|
return new LinkedStrongKeySoftValueNode |
2093 |
|
(locator, key, value, cchm, linkage); |
2094 |
|
} |
2095 |
< |
} |
2095 |
> |
} |
2096 |
|
|
2097 |
|
// Weak keys |
2098 |
|
|
2106 |
|
this.cchm = cchm; |
2107 |
|
} |
2108 |
|
public final int getLocator() { return locator; } |
2109 |
< |
public final void onReclamation() { |
2109 |
> |
public final void onReclamation() { |
2110 |
|
clear(); |
2111 |
|
cchm.removeIfReclaimed(this); |
2112 |
|
} |
2113 |
|
} |
2114 |
|
|
2115 |
< |
static abstract class WeakKeySelfValueNode |
2115 |
> |
static abstract class WeakKeySelfValueNode |
2116 |
|
extends WeakKeyNode { |
2117 |
|
WeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) { |
2118 |
|
super(locator, key, cchm); |
2121 |
|
public final void setValue(Object value) { } |
2122 |
|
} |
2123 |
|
|
2124 |
< |
static final class TerminalWeakKeySelfValueNode |
2124 |
> |
static final class TerminalWeakKeySelfValueNode |
2125 |
|
extends WeakKeySelfValueNode { |
2126 |
|
TerminalWeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) { |
2127 |
|
super(locator, key, cchm); |
2130 |
|
public final void setLinkage(Node r) { } |
2131 |
|
} |
2132 |
|
|
2133 |
< |
static final class LinkedWeakKeySelfValueNode |
2133 |
> |
static final class LinkedWeakKeySelfValueNode |
2134 |
|
extends WeakKeySelfValueNode { |
2135 |
|
volatile Node linkage; |
2136 |
|
LinkedWeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm, |
2146 |
|
implements NodeFactory, Serializable { |
2147 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2148 |
|
public final Node newNode(int locator, |
2149 |
< |
Object key, Object value, |
2149 |
> |
Object key, Object value, |
2150 |
|
CustomConcurrentHashMap cchm, |
2151 |
|
Node linkage) { |
2152 |
|
if (linkage == null) |
2156 |
|
return new LinkedWeakKeySelfValueNode |
2157 |
|
(locator, key, cchm, linkage); |
2158 |
|
} |
2159 |
< |
} |
2159 |
> |
} |
2160 |
|
|
2161 |
|
|
2162 |
< |
static abstract class WeakKeyStrongValueNode |
2162 |
> |
static abstract class WeakKeyStrongValueNode |
2163 |
|
extends WeakKeyNode { |
2164 |
|
volatile Object value; |
2165 |
|
WeakKeyStrongValueNode(int locator, Object key, Object value, CustomConcurrentHashMap cchm) { |
2170 |
|
public final void setValue(Object value) { this.value = value; } |
2171 |
|
} |
2172 |
|
|
2173 |
< |
static final class TerminalWeakKeyStrongValueNode |
2173 |
> |
static final class TerminalWeakKeyStrongValueNode |
2174 |
|
extends WeakKeyStrongValueNode { |
2175 |
|
TerminalWeakKeyStrongValueNode(int locator, |
2176 |
|
Object key, Object value, CustomConcurrentHashMap cchm) { |
2180 |
|
public final void setLinkage(Node r) { } |
2181 |
|
} |
2182 |
|
|
2183 |
< |
static final class LinkedWeakKeyStrongValueNode |
2183 |
> |
static final class LinkedWeakKeyStrongValueNode |
2184 |
|
extends WeakKeyStrongValueNode { |
2185 |
|
volatile Node linkage; |
2186 |
|
LinkedWeakKeyStrongValueNode(int locator, |
2193 |
|
public final void setLinkage(Node r) { linkage = r; } |
2194 |
|
} |
2195 |
|
|
2196 |
< |
static final class WeakKeyStrongValueNodeFactory |
2196 |
> |
static final class WeakKeyStrongValueNodeFactory |
2197 |
|
implements NodeFactory, Serializable { |
2198 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2199 |
|
public final Node newNode(int locator, |
2200 |
< |
Object key, Object value, |
2200 |
> |
Object key, Object value, |
2201 |
|
CustomConcurrentHashMap cchm, |
2202 |
|
Node linkage) { |
2203 |
|
if (linkage == null) |
2207 |
|
return new LinkedWeakKeyStrongValueNode |
2208 |
|
(locator, key, value, cchm, linkage); |
2209 |
|
} |
2210 |
< |
} |
2210 |
> |
} |
2211 |
|
|
2212 |
< |
static abstract class WeakKeyIntValueNode |
2212 |
> |
static abstract class WeakKeyIntValueNode |
2213 |
|
extends WeakKeyNode { |
2214 |
|
volatile int value; |
2215 |
|
WeakKeyIntValueNode(int locator, Object key, Object value, |
2218 |
|
this.value = ((Integer)value).intValue(); |
2219 |
|
} |
2220 |
|
public final Object getValue() { return Integer.valueOf(value); } |
2221 |
< |
public final void setValue(Object value) { |
2221 |
> |
public final void setValue(Object value) { |
2222 |
|
this.value = ((Integer)value).intValue(); |
2223 |
|
} |
2224 |
|
} |
2225 |
|
|
2226 |
< |
static final class TerminalWeakKeyIntValueNode |
2226 |
> |
static final class TerminalWeakKeyIntValueNode |
2227 |
|
extends WeakKeyIntValueNode { |
2228 |
|
TerminalWeakKeyIntValueNode(int locator, |
2229 |
|
Object key, Object value, |
2234 |
|
public final void setLinkage(Node r) { } |
2235 |
|
} |
2236 |
|
|
2237 |
< |
static final class LinkedWeakKeyIntValueNode |
2237 |
> |
static final class LinkedWeakKeyIntValueNode |
2238 |
|
extends WeakKeyIntValueNode { |
2239 |
|
volatile Node linkage; |
2240 |
|
LinkedWeakKeyIntValueNode(int locator, |
2241 |
< |
Object key, Object value, |
2241 |
> |
Object key, Object value, |
2242 |
|
CustomConcurrentHashMap cchm, |
2243 |
|
Node linkage) { |
2244 |
|
super(locator, key, value, cchm); |
2248 |
|
public final void setLinkage(Node r) { linkage = r; } |
2249 |
|
} |
2250 |
|
|
2251 |
< |
static final class WeakKeyIntValueNodeFactory |
2251 |
> |
static final class WeakKeyIntValueNodeFactory |
2252 |
|
implements NodeFactory, Serializable { |
2253 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2254 |
|
public final Node newNode(int locator, |
2255 |
< |
Object key, Object value, |
2255 |
> |
Object key, Object value, |
2256 |
|
CustomConcurrentHashMap cchm, |
2257 |
|
Node linkage) { |
2258 |
|
if (linkage == null) |
2262 |
|
return new LinkedWeakKeyIntValueNode |
2263 |
|
(locator, key, value, cchm, linkage); |
2264 |
|
} |
2265 |
< |
} |
2265 |
> |
} |
2266 |
|
|
2267 |
< |
static abstract class WeakKeyWeakValueNode |
2267 |
> |
static abstract class WeakKeyWeakValueNode |
2268 |
|
extends WeakKeyNode { |
2269 |
|
volatile EmbeddedWeakReference valueRef; |
2270 |
< |
WeakKeyWeakValueNode(int locator, Object key, Object value, |
2270 |
> |
WeakKeyWeakValueNode(int locator, Object key, Object value, |
2271 |
|
CustomConcurrentHashMap cchm) { |
2272 |
|
super(locator, key, cchm); |
2273 |
|
if (value != null) |
2285 |
|
} |
2286 |
|
} |
2287 |
|
|
2288 |
< |
static final class TerminalWeakKeyWeakValueNode |
2288 |
> |
static final class TerminalWeakKeyWeakValueNode |
2289 |
|
extends WeakKeyWeakValueNode { |
2290 |
|
TerminalWeakKeyWeakValueNode(int locator, |
2291 |
< |
Object key, Object value, |
2291 |
> |
Object key, Object value, |
2292 |
|
CustomConcurrentHashMap cchm) { |
2293 |
|
super(locator, key, value, cchm); |
2294 |
|
} |
2296 |
|
public final void setLinkage(Node r) { } |
2297 |
|
} |
2298 |
|
|
2299 |
< |
static final class LinkedWeakKeyWeakValueNode |
2299 |
> |
static final class LinkedWeakKeyWeakValueNode |
2300 |
|
extends WeakKeyWeakValueNode { |
2301 |
|
volatile Node linkage; |
2302 |
|
LinkedWeakKeyWeakValueNode(int locator, |
2303 |
< |
Object key, Object value, |
2303 |
> |
Object key, Object value, |
2304 |
|
CustomConcurrentHashMap cchm, |
2305 |
|
Node linkage) { |
2306 |
|
super(locator, key, value, cchm); |
2310 |
|
public final void setLinkage(Node r) { linkage = r; } |
2311 |
|
} |
2312 |
|
|
2313 |
< |
static final class WeakKeyWeakValueNodeFactory |
2313 |
> |
static final class WeakKeyWeakValueNodeFactory |
2314 |
|
implements NodeFactory, Serializable { |
2315 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2316 |
< |
public final Node newNode(int locator, |
2317 |
< |
Object key, Object value, |
2316 |
> |
public final Node newNode(int locator, |
2317 |
> |
Object key, Object value, |
2318 |
|
CustomConcurrentHashMap cchm, |
2319 |
|
Node linkage) { |
2320 |
|
if (linkage == null) |
2324 |
|
return new LinkedWeakKeyWeakValueNode |
2325 |
|
(locator, key, value, cchm, linkage); |
2326 |
|
} |
2327 |
< |
} |
2327 |
> |
} |
2328 |
|
|
2329 |
|
|
2330 |
< |
static abstract class WeakKeySoftValueNode |
2330 |
> |
static abstract class WeakKeySoftValueNode |
2331 |
|
extends WeakKeyNode { |
2332 |
|
volatile EmbeddedSoftReference valueRef; |
2333 |
< |
WeakKeySoftValueNode(int locator, Object key, Object value, |
2333 |
> |
WeakKeySoftValueNode(int locator, Object key, Object value, |
2334 |
|
CustomConcurrentHashMap cchm) { |
2335 |
|
super(locator, key, cchm); |
2336 |
|
if (value != null) |
2348 |
|
} |
2349 |
|
} |
2350 |
|
|
2351 |
< |
static final class TerminalWeakKeySoftValueNode |
2351 |
> |
static final class TerminalWeakKeySoftValueNode |
2352 |
|
extends WeakKeySoftValueNode { |
2353 |
|
TerminalWeakKeySoftValueNode(int locator, |
2354 |
< |
Object key, Object value, |
2354 |
> |
Object key, Object value, |
2355 |
|
CustomConcurrentHashMap cchm) { |
2356 |
|
super(locator, key, value, cchm); |
2357 |
|
} |
2359 |
|
public final void setLinkage(Node r) { } |
2360 |
|
} |
2361 |
|
|
2362 |
< |
static final class LinkedWeakKeySoftValueNode |
2362 |
> |
static final class LinkedWeakKeySoftValueNode |
2363 |
|
extends WeakKeySoftValueNode { |
2364 |
|
volatile Node linkage; |
2365 |
|
LinkedWeakKeySoftValueNode(int locator, |
2366 |
< |
Object key, Object value, |
2366 |
> |
Object key, Object value, |
2367 |
|
CustomConcurrentHashMap cchm, |
2368 |
|
Node linkage) { |
2369 |
|
super(locator, key, value, cchm); |
2373 |
|
public final void setLinkage(Node r) { linkage = r; } |
2374 |
|
} |
2375 |
|
|
2376 |
< |
static final class WeakKeySoftValueNodeFactory |
2376 |
> |
static final class WeakKeySoftValueNodeFactory |
2377 |
|
implements NodeFactory, Serializable { |
2378 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2379 |
< |
public final Node newNode(int locator, |
2380 |
< |
Object key, Object value, |
2379 |
> |
public final Node newNode(int locator, |
2380 |
> |
Object key, Object value, |
2381 |
|
CustomConcurrentHashMap cchm, |
2382 |
|
Node linkage) { |
2383 |
|
if (linkage == null) |
2387 |
|
return new LinkedWeakKeySoftValueNode |
2388 |
|
(locator, key, value, cchm, linkage); |
2389 |
|
} |
2390 |
< |
} |
2390 |
> |
} |
2391 |
|
|
2392 |
|
// Soft keys |
2393 |
|
|
2401 |
|
this.cchm = cchm; |
2402 |
|
} |
2403 |
|
public final int getLocator() { return locator; } |
2404 |
< |
public final void onReclamation() { |
2404 |
> |
public final void onReclamation() { |
2405 |
|
clear(); |
2406 |
|
cchm.removeIfReclaimed(this); |
2407 |
|
} |
2408 |
|
} |
2409 |
|
|
2410 |
< |
static abstract class SoftKeySelfValueNode |
2410 |
> |
static abstract class SoftKeySelfValueNode |
2411 |
|
extends SoftKeyNode { |
2412 |
|
SoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) { |
2413 |
|
super(locator, key, cchm); |
2416 |
|
public final void setValue(Object value) { } |
2417 |
|
} |
2418 |
|
|
2419 |
< |
static final class TerminalSoftKeySelfValueNode |
2419 |
> |
static final class TerminalSoftKeySelfValueNode |
2420 |
|
extends SoftKeySelfValueNode { |
2421 |
|
TerminalSoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) { |
2422 |
|
super(locator, key, cchm); |
2425 |
|
public final void setLinkage(Node r) { } |
2426 |
|
} |
2427 |
|
|
2428 |
< |
static final class LinkedSoftKeySelfValueNode |
2428 |
> |
static final class LinkedSoftKeySelfValueNode |
2429 |
|
extends SoftKeySelfValueNode { |
2430 |
|
volatile Node linkage; |
2431 |
|
LinkedSoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm, |
2441 |
|
implements NodeFactory, Serializable { |
2442 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2443 |
|
public final Node newNode(int locator, |
2444 |
< |
Object key, Object value, |
2444 |
> |
Object key, Object value, |
2445 |
|
CustomConcurrentHashMap cchm, |
2446 |
|
Node linkage) { |
2447 |
|
if (linkage == null) |
2451 |
|
return new LinkedSoftKeySelfValueNode |
2452 |
|
(locator, key, cchm, linkage); |
2453 |
|
} |
2454 |
< |
} |
2454 |
> |
} |
2455 |
|
|
2456 |
|
|
2457 |
< |
static abstract class SoftKeyStrongValueNode |
2457 |
> |
static abstract class SoftKeyStrongValueNode |
2458 |
|
extends SoftKeyNode { |
2459 |
|
volatile Object value; |
2460 |
|
SoftKeyStrongValueNode(int locator, Object key, Object value, CustomConcurrentHashMap cchm) { |
2465 |
|
public final void setValue(Object value) { this.value = value; } |
2466 |
|
} |
2467 |
|
|
2468 |
< |
static final class TerminalSoftKeyStrongValueNode |
2468 |
> |
static final class TerminalSoftKeyStrongValueNode |
2469 |
|
extends SoftKeyStrongValueNode { |
2470 |
|
TerminalSoftKeyStrongValueNode(int locator, |
2471 |
|
Object key, Object value, CustomConcurrentHashMap cchm) { |
2475 |
|
public final void setLinkage(Node r) { } |
2476 |
|
} |
2477 |
|
|
2478 |
< |
static final class LinkedSoftKeyStrongValueNode |
2478 |
> |
static final class LinkedSoftKeyStrongValueNode |
2479 |
|
extends SoftKeyStrongValueNode { |
2480 |
|
volatile Node linkage; |
2481 |
|
LinkedSoftKeyStrongValueNode(int locator, |
2488 |
|
public final void setLinkage(Node r) { linkage = r; } |
2489 |
|
} |
2490 |
|
|
2491 |
< |
static final class SoftKeyStrongValueNodeFactory |
2491 |
> |
static final class SoftKeyStrongValueNodeFactory |
2492 |
|
implements NodeFactory, Serializable { |
2493 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2494 |
|
public final Node newNode(int locator, |
2495 |
< |
Object key, Object value, |
2495 |
> |
Object key, Object value, |
2496 |
|
CustomConcurrentHashMap cchm, |
2497 |
|
Node linkage) { |
2498 |
|
if (linkage == null) |
2502 |
|
return new LinkedSoftKeyStrongValueNode |
2503 |
|
(locator, key, value, cchm, linkage); |
2504 |
|
} |
2505 |
< |
} |
2505 |
> |
} |
2506 |
|
|
2507 |
< |
static abstract class SoftKeyIntValueNode |
2507 |
> |
static abstract class SoftKeyIntValueNode |
2508 |
|
extends SoftKeyNode { |
2509 |
|
volatile int value; |
2510 |
|
SoftKeyIntValueNode(int locator, Object key, Object value, |
2513 |
|
this.value = ((Integer)value).intValue(); |
2514 |
|
} |
2515 |
|
public final Object getValue() { return Integer.valueOf(value); } |
2516 |
< |
public final void setValue(Object value) { |
2516 |
> |
public final void setValue(Object value) { |
2517 |
|
this.value = ((Integer)value).intValue(); |
2518 |
|
} |
2519 |
|
} |
2520 |
|
|
2521 |
< |
static final class TerminalSoftKeyIntValueNode |
2521 |
> |
static final class TerminalSoftKeyIntValueNode |
2522 |
|
extends SoftKeyIntValueNode { |
2523 |
|
TerminalSoftKeyIntValueNode(int locator, |
2524 |
|
Object key, Object value, |
2529 |
|
public final void setLinkage(Node r) { } |
2530 |
|
} |
2531 |
|
|
2532 |
< |
static final class LinkedSoftKeyIntValueNode |
2532 |
> |
static final class LinkedSoftKeyIntValueNode |
2533 |
|
extends SoftKeyIntValueNode { |
2534 |
|
volatile Node linkage; |
2535 |
|
LinkedSoftKeyIntValueNode(int locator, |
2536 |
< |
Object key, Object value, |
2536 |
> |
Object key, Object value, |
2537 |
|
CustomConcurrentHashMap cchm, |
2538 |
|
Node linkage) { |
2539 |
|
super(locator, key, value, cchm); |
2543 |
|
public final void setLinkage(Node r) { linkage = r; } |
2544 |
|
} |
2545 |
|
|
2546 |
< |
static final class SoftKeyIntValueNodeFactory |
2546 |
> |
static final class SoftKeyIntValueNodeFactory |
2547 |
|
implements NodeFactory, Serializable { |
2548 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2549 |
|
public final Node newNode(int locator, |
2550 |
< |
Object key, Object value, |
2550 |
> |
Object key, Object value, |
2551 |
|
CustomConcurrentHashMap cchm, |
2552 |
|
Node linkage) { |
2553 |
|
if (linkage == null) |
2557 |
|
return new LinkedSoftKeyIntValueNode |
2558 |
|
(locator, key, value, cchm, linkage); |
2559 |
|
} |
2560 |
< |
} |
2560 |
> |
} |
2561 |
|
|
2562 |
< |
static abstract class SoftKeyWeakValueNode |
2562 |
> |
static abstract class SoftKeyWeakValueNode |
2563 |
|
extends SoftKeyNode { |
2564 |
|
volatile EmbeddedWeakReference valueRef; |
2565 |
< |
SoftKeyWeakValueNode(int locator, Object key, Object value, |
2565 |
> |
SoftKeyWeakValueNode(int locator, Object key, Object value, |
2566 |
|
CustomConcurrentHashMap cchm) { |
2567 |
|
super(locator, key, cchm); |
2568 |
|
if (value != null) |
2580 |
|
} |
2581 |
|
} |
2582 |
|
|
2583 |
< |
static final class TerminalSoftKeyWeakValueNode |
2583 |
> |
static final class TerminalSoftKeyWeakValueNode |
2584 |
|
extends SoftKeyWeakValueNode { |
2585 |
|
TerminalSoftKeyWeakValueNode(int locator, |
2586 |
< |
Object key, Object value, |
2586 |
> |
Object key, Object value, |
2587 |
|
CustomConcurrentHashMap cchm) { |
2588 |
|
super(locator, key, value, cchm); |
2589 |
|
} |
2591 |
|
public final void setLinkage(Node r) { } |
2592 |
|
} |
2593 |
|
|
2594 |
< |
static final class LinkedSoftKeyWeakValueNode |
2594 |
> |
static final class LinkedSoftKeyWeakValueNode |
2595 |
|
extends SoftKeyWeakValueNode { |
2596 |
|
volatile Node linkage; |
2597 |
|
LinkedSoftKeyWeakValueNode(int locator, |
2598 |
< |
Object key, Object value, |
2598 |
> |
Object key, Object value, |
2599 |
|
CustomConcurrentHashMap cchm, |
2600 |
|
Node linkage) { |
2601 |
|
super(locator, key, value, cchm); |
2605 |
|
public final void setLinkage(Node r) { linkage = r; } |
2606 |
|
} |
2607 |
|
|
2608 |
< |
static final class SoftKeyWeakValueNodeFactory |
2608 |
> |
static final class SoftKeyWeakValueNodeFactory |
2609 |
|
implements NodeFactory, Serializable { |
2610 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2611 |
< |
public final Node newNode(int locator, |
2612 |
< |
Object key, Object value, |
2611 |
> |
public final Node newNode(int locator, |
2612 |
> |
Object key, Object value, |
2613 |
|
CustomConcurrentHashMap cchm, |
2614 |
|
Node linkage) { |
2615 |
|
if (linkage == null) |
2619 |
|
return new LinkedSoftKeyWeakValueNode |
2620 |
|
(locator, key, value, cchm, linkage); |
2621 |
|
} |
2622 |
< |
} |
2622 |
> |
} |
2623 |
|
|
2624 |
|
|
2625 |
< |
static abstract class SoftKeySoftValueNode |
2625 |
> |
static abstract class SoftKeySoftValueNode |
2626 |
|
extends SoftKeyNode { |
2627 |
|
volatile EmbeddedSoftReference valueRef; |
2628 |
< |
SoftKeySoftValueNode(int locator, Object key, Object value, |
2628 |
> |
SoftKeySoftValueNode(int locator, Object key, Object value, |
2629 |
|
CustomConcurrentHashMap cchm) { |
2630 |
|
super(locator, key, cchm); |
2631 |
|
if (value != null) |
2643 |
|
} |
2644 |
|
} |
2645 |
|
|
2646 |
< |
static final class TerminalSoftKeySoftValueNode |
2646 |
> |
static final class TerminalSoftKeySoftValueNode |
2647 |
|
extends SoftKeySoftValueNode { |
2648 |
|
TerminalSoftKeySoftValueNode(int locator, |
2649 |
< |
Object key, Object value, |
2649 |
> |
Object key, Object value, |
2650 |
|
CustomConcurrentHashMap cchm) { |
2651 |
|
super(locator, key, value, cchm); |
2652 |
|
} |
2654 |
|
public final void setLinkage(Node r) { } |
2655 |
|
} |
2656 |
|
|
2657 |
< |
static final class LinkedSoftKeySoftValueNode |
2657 |
> |
static final class LinkedSoftKeySoftValueNode |
2658 |
|
extends SoftKeySoftValueNode { |
2659 |
|
volatile Node linkage; |
2660 |
|
LinkedSoftKeySoftValueNode(int locator, |
2661 |
< |
Object key, Object value, |
2661 |
> |
Object key, Object value, |
2662 |
|
CustomConcurrentHashMap cchm, |
2663 |
|
Node linkage) { |
2664 |
|
super(locator, key, value, cchm); |
2668 |
|
public final void setLinkage(Node r) { linkage = r; } |
2669 |
|
} |
2670 |
|
|
2671 |
< |
static final class SoftKeySoftValueNodeFactory |
2671 |
> |
static final class SoftKeySoftValueNodeFactory |
2672 |
|
implements NodeFactory, Serializable { |
2673 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2674 |
< |
public final Node newNode(int locator, |
2675 |
< |
Object key, Object value, |
2674 |
> |
public final Node newNode(int locator, |
2675 |
> |
Object key, Object value, |
2676 |
|
CustomConcurrentHashMap cchm, |
2677 |
|
Node linkage) { |
2678 |
|
if (linkage == null) |
2682 |
|
return new LinkedSoftKeySoftValueNode |
2683 |
|
(locator, key, value, cchm, linkage); |
2684 |
|
} |
2685 |
< |
} |
2685 |
> |
} |
2686 |
|
|
2687 |
|
static abstract class IntKeyNode implements Node { |
2688 |
|
final int key; |
2694 |
|
} |
2695 |
|
|
2696 |
|
|
2697 |
< |
static abstract class IntKeySelfValueNode |
2697 |
> |
static abstract class IntKeySelfValueNode |
2698 |
|
extends IntKeyNode { |
2699 |
|
IntKeySelfValueNode(int locator, Object key) { |
2700 |
|
super(locator, key); |
2704 |
|
public final void onReclamation() { } |
2705 |
|
} |
2706 |
|
|
2707 |
< |
static final class TerminalIntKeySelfValueNode |
2707 |
> |
static final class TerminalIntKeySelfValueNode |
2708 |
|
extends IntKeySelfValueNode { |
2709 |
|
TerminalIntKeySelfValueNode(int locator, Object key) { |
2710 |
|
super(locator, key); |
2713 |
|
public final void setLinkage(Node r) { } |
2714 |
|
} |
2715 |
|
|
2716 |
< |
static final class LinkedIntKeySelfValueNode |
2716 |
> |
static final class LinkedIntKeySelfValueNode |
2717 |
|
extends IntKeySelfValueNode { |
2718 |
|
volatile Node linkage; |
2719 |
< |
LinkedIntKeySelfValueNode(int locator, Object key, |
2719 |
> |
LinkedIntKeySelfValueNode(int locator, Object key, |
2720 |
|
Node linkage) { |
2721 |
|
super(locator, key); |
2722 |
|
this.linkage = linkage; |
2729 |
|
implements NodeFactory, Serializable { |
2730 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2731 |
|
public final Node newNode(int locator, |
2732 |
< |
Object key, Object value, |
2732 |
> |
Object key, Object value, |
2733 |
|
CustomConcurrentHashMap cchm, |
2734 |
|
Node linkage) { |
2735 |
|
if (linkage == null) |
2739 |
|
return new LinkedIntKeySelfValueNode |
2740 |
|
(locator, key, linkage); |
2741 |
|
} |
2742 |
< |
} |
2742 |
> |
} |
2743 |
|
|
2744 |
< |
static abstract class IntKeyStrongValueNode |
2744 |
> |
static abstract class IntKeyStrongValueNode |
2745 |
|
extends IntKeyNode { |
2746 |
|
volatile Object value; |
2747 |
|
IntKeyStrongValueNode(int locator, Object key, Object value) { |
2753 |
|
public final void onReclamation() { } |
2754 |
|
} |
2755 |
|
|
2756 |
< |
static final class TerminalIntKeyStrongValueNode |
2756 |
> |
static final class TerminalIntKeyStrongValueNode |
2757 |
|
extends IntKeyStrongValueNode { |
2758 |
|
TerminalIntKeyStrongValueNode(int locator, |
2759 |
|
Object key, Object value) { |
2763 |
|
public final void setLinkage(Node r) { } |
2764 |
|
} |
2765 |
|
|
2766 |
< |
static final class LinkedIntKeyStrongValueNode |
2766 |
> |
static final class LinkedIntKeyStrongValueNode |
2767 |
|
extends IntKeyStrongValueNode { |
2768 |
|
volatile Node linkage; |
2769 |
|
LinkedIntKeyStrongValueNode(int locator, |
2770 |
< |
Object key, Object value, |
2770 |
> |
Object key, Object value, |
2771 |
|
Node linkage) { |
2772 |
|
super(locator, key, value); |
2773 |
|
this.linkage = linkage; |
2776 |
|
public final void setLinkage(Node r) { linkage = r; } |
2777 |
|
} |
2778 |
|
|
2779 |
< |
static final class IntKeyStrongValueNodeFactory |
2779 |
> |
static final class IntKeyStrongValueNodeFactory |
2780 |
|
implements NodeFactory, Serializable { |
2781 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2782 |
|
public final Node newNode(int locator, |
2783 |
< |
Object key, Object value, |
2783 |
> |
Object key, Object value, |
2784 |
|
CustomConcurrentHashMap cchm, |
2785 |
|
Node linkage) { |
2786 |
|
if (linkage == null) |
2790 |
|
return new LinkedIntKeyStrongValueNode |
2791 |
|
(locator, key, value, linkage); |
2792 |
|
} |
2793 |
< |
} |
2793 |
> |
} |
2794 |
|
|
2795 |
< |
static abstract class IntKeyIntValueNode |
2795 |
> |
static abstract class IntKeyIntValueNode |
2796 |
|
extends IntKeyNode { |
2797 |
|
volatile int value; |
2798 |
|
IntKeyIntValueNode(int locator, Object key, Object value) { |
2800 |
|
this.value = ((Integer)value).intValue(); |
2801 |
|
} |
2802 |
|
public final Object getValue() { return Integer.valueOf(value); } |
2803 |
< |
public final void setValue(Object value) { |
2803 |
> |
public final void setValue(Object value) { |
2804 |
|
this.value = ((Integer)value).intValue(); |
2805 |
|
} |
2806 |
|
public final void onReclamation() { } |
2807 |
|
} |
2808 |
|
|
2809 |
< |
static final class TerminalIntKeyIntValueNode |
2809 |
> |
static final class TerminalIntKeyIntValueNode |
2810 |
|
extends IntKeyIntValueNode { |
2811 |
|
TerminalIntKeyIntValueNode(int locator, |
2812 |
|
Object key, Object value) { |
2816 |
|
public final void setLinkage(Node r) { } |
2817 |
|
} |
2818 |
|
|
2819 |
< |
static final class LinkedIntKeyIntValueNode |
2819 |
> |
static final class LinkedIntKeyIntValueNode |
2820 |
|
extends IntKeyIntValueNode { |
2821 |
|
volatile Node linkage; |
2822 |
|
LinkedIntKeyIntValueNode(int locator, |
2823 |
< |
Object key, Object value, |
2823 |
> |
Object key, Object value, |
2824 |
|
Node linkage) { |
2825 |
|
super(locator, key, value); |
2826 |
|
this.linkage = linkage; |
2829 |
|
public final void setLinkage(Node r) { linkage = r; } |
2830 |
|
} |
2831 |
|
|
2832 |
< |
static final class IntKeyIntValueNodeFactory |
2832 |
> |
static final class IntKeyIntValueNodeFactory |
2833 |
|
implements NodeFactory, Serializable { |
2834 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2835 |
|
public final Node newNode(int locator, |
2836 |
< |
Object key, Object value, |
2836 |
> |
Object key, Object value, |
2837 |
|
CustomConcurrentHashMap cchm, |
2838 |
|
Node linkage) { |
2839 |
|
if (linkage == null) |
2843 |
|
return new LinkedIntKeyIntValueNode |
2844 |
|
(locator, key, value, linkage); |
2845 |
|
} |
2846 |
< |
} |
2846 |
> |
} |
2847 |
|
|
2848 |
< |
static abstract class IntKeyWeakValueNode |
2848 |
> |
static abstract class IntKeyWeakValueNode |
2849 |
|
extends IntKeyNode { |
2850 |
|
volatile EmbeddedWeakReference valueRef; |
2851 |
|
final CustomConcurrentHashMap cchm; |
2852 |
< |
IntKeyWeakValueNode(int locator, Object key, Object value, |
2852 |
> |
IntKeyWeakValueNode(int locator, Object key, Object value, |
2853 |
|
CustomConcurrentHashMap cchm) { |
2854 |
|
super(locator, key); |
2855 |
|
this.cchm = cchm; |
2871 |
|
} |
2872 |
|
} |
2873 |
|
|
2874 |
< |
static final class TerminalIntKeyWeakValueNode |
2874 |
> |
static final class TerminalIntKeyWeakValueNode |
2875 |
|
extends IntKeyWeakValueNode { |
2876 |
|
TerminalIntKeyWeakValueNode(int locator, |
2877 |
< |
Object key, Object value, |
2877 |
> |
Object key, Object value, |
2878 |
|
CustomConcurrentHashMap cchm) { |
2879 |
|
super(locator, key, value, cchm); |
2880 |
|
} |
2882 |
|
public final void setLinkage(Node r) { } |
2883 |
|
} |
2884 |
|
|
2885 |
< |
static final class LinkedIntKeyWeakValueNode |
2885 |
> |
static final class LinkedIntKeyWeakValueNode |
2886 |
|
extends IntKeyWeakValueNode { |
2887 |
|
volatile Node linkage; |
2888 |
|
LinkedIntKeyWeakValueNode(int locator, |
2889 |
< |
Object key, Object value, |
2889 |
> |
Object key, Object value, |
2890 |
|
CustomConcurrentHashMap cchm, |
2891 |
|
Node linkage) { |
2892 |
|
super(locator, key, value, cchm); |
2896 |
|
public final void setLinkage(Node r) { linkage = r; } |
2897 |
|
} |
2898 |
|
|
2899 |
< |
static final class IntKeyWeakValueNodeFactory |
2899 |
> |
static final class IntKeyWeakValueNodeFactory |
2900 |
|
implements NodeFactory, Serializable { |
2901 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2902 |
< |
public final Node newNode(int locator, |
2903 |
< |
Object key, Object value, |
2902 |
> |
public final Node newNode(int locator, |
2903 |
> |
Object key, Object value, |
2904 |
|
CustomConcurrentHashMap cchm, |
2905 |
|
Node linkage) { |
2906 |
|
if (linkage == null) |
2910 |
|
return new LinkedIntKeyWeakValueNode |
2911 |
|
(locator, key, value, cchm, linkage); |
2912 |
|
} |
2913 |
< |
} |
2913 |
> |
} |
2914 |
|
|
2915 |
|
|
2916 |
< |
static abstract class IntKeySoftValueNode |
2916 |
> |
static abstract class IntKeySoftValueNode |
2917 |
|
extends IntKeyNode { |
2918 |
|
volatile EmbeddedSoftReference valueRef; |
2919 |
|
final CustomConcurrentHashMap cchm; |
2920 |
< |
IntKeySoftValueNode(int locator, Object key, Object value, |
2920 |
> |
IntKeySoftValueNode(int locator, Object key, Object value, |
2921 |
|
CustomConcurrentHashMap cchm) { |
2922 |
|
super(locator, key); |
2923 |
|
this.cchm = cchm; |
2939 |
|
} |
2940 |
|
} |
2941 |
|
|
2942 |
< |
static final class TerminalIntKeySoftValueNode |
2942 |
> |
static final class TerminalIntKeySoftValueNode |
2943 |
|
extends IntKeySoftValueNode { |
2944 |
|
TerminalIntKeySoftValueNode(int locator, |
2945 |
< |
Object key, Object value, |
2945 |
> |
Object key, Object value, |
2946 |
|
CustomConcurrentHashMap cchm) { |
2947 |
|
super(locator, key, value, cchm); |
2948 |
|
} |
2950 |
|
public final void setLinkage(Node r) { } |
2951 |
|
} |
2952 |
|
|
2953 |
< |
static final class LinkedIntKeySoftValueNode |
2953 |
> |
static final class LinkedIntKeySoftValueNode |
2954 |
|
extends IntKeySoftValueNode { |
2955 |
|
volatile Node linkage; |
2956 |
|
LinkedIntKeySoftValueNode(int locator, |
2957 |
< |
Object key, Object value, |
2957 |
> |
Object key, Object value, |
2958 |
|
CustomConcurrentHashMap cchm, |
2959 |
|
Node linkage) { |
2960 |
|
super(locator, key, value, cchm); |
2964 |
|
public final void setLinkage(Node r) { linkage = r; } |
2965 |
|
} |
2966 |
|
|
2967 |
< |
static final class IntKeySoftValueNodeFactory |
2967 |
> |
static final class IntKeySoftValueNodeFactory |
2968 |
|
implements NodeFactory, Serializable { |
2969 |
|
private static final long serialVersionUID = 7249069346764182397L; |
2970 |
< |
public final Node newNode(int locator, |
2971 |
< |
Object key, Object value, |
2970 |
> |
public final Node newNode(int locator, |
2971 |
> |
Object key, Object value, |
2972 |
|
CustomConcurrentHashMap cchm, |
2973 |
|
Node linkage) { |
2974 |
|
if (linkage == null) |
2978 |
|
return new LinkedIntKeySoftValueNode |
2979 |
|
(locator, key, value, cchm, linkage); |
2980 |
|
} |
2981 |
< |
} |
2981 |
> |
} |
2982 |
|
|
2983 |
|
|
2984 |
|
|
3032 |
|
} |
3033 |
|
|
3034 |
|
// Fenced store into segment table array. Unneeded when we have Fences |
3035 |
< |
static final void storeNode(Node[] table, |
3035 |
> |
static final void storeNode(Node[] table, |
3036 |
|
int i, Node r) { |
3037 |
< |
_unsafe.putOrderedObject(table, (i << tableShift) + tableBase, r); |
3037 |
> |
long nodeOffset = ((long) i << tableShift) + tableBase; |
3038 |
> |
_unsafe.putOrderedObject(table, nodeOffset, r); |
3039 |
|
} |
3040 |
|
|
3041 |
< |
static final void storeSegment(Segment[] segs, |
3041 |
> |
static final void storeSegment(Segment[] segs, |
3042 |
|
int i, Segment s) { |
3043 |
< |
_unsafe.putOrderedObject(segs, (i << segmentsShift) + segmentsBase, s); |
3043 |
> |
long segmentOffset = ((long) i << segmentsShift) + segmentsBase; |
3044 |
> |
_unsafe.putOrderedObject(segs, segmentOffset, s); |
3045 |
|
} |
3046 |
|
|
3047 |
|
|
3048 |
|
} |
3042 |
– |
|