ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/extra166y/CustomConcurrentHashMap.java
(Generate patch)

Comparing jsr166/src/extra166y/CustomConcurrentHashMap.java (file contents):
Revision 1.2 by dl, Tue Jun 30 14:56:53 2009 UTC vs.
Revision 1.5 by jsr166, Tue Oct 6 19:02:48 2009 UTC

# Line 31 | Line 31 | import sun.misc.Unsafe;
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>
# Line 55 | Line 55 | import sun.misc.Unsafe;
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   *        },
# Line 69 | Line 69 | import sun.misc.Unsafe;
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
# Line 81 | Line 81 | import sun.misc.Unsafe;
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.
# Line 126 | Line 126 | public class CustomConcurrentHashMap<K,
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.
# Line 138 | Line 138 | public class CustomConcurrentHashMap<K,
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  
# Line 184 | Line 184 | public class CustomConcurrentHashMap<K,
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
# Line 194 | Line 194 | public class CustomConcurrentHashMap<K,
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); }
# Line 212 | Line 212 | public class CustomConcurrentHashMap<K,
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          /**
# Line 275 | Line 275 | public class CustomConcurrentHashMap<K,
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  
# Line 303 | Line 304 | public class CustomConcurrentHashMap<K,
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           */
# Line 332 | Line 333 | public class CustomConcurrentHashMap<K,
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
# Line 355 | Line 356 | public class CustomConcurrentHashMap<K,
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;
# Line 396 | Line 397 | public class CustomConcurrentHashMap<K,
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;
# Line 436 | Line 437 | public class CustomConcurrentHashMap<K,
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                      }
# Line 477 | Line 478 | public class CustomConcurrentHashMap<K,
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       */
# Line 515 | Line 516 | public class CustomConcurrentHashMap<K,
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)
# Line 554 | Line 555 | public class CustomConcurrentHashMap<K,
555                                     Strength valueStrength,
556                                     Equivalence<? super V> valueEquivalence,
557                                     int expectedSize) {
558 <        this(keyStrength.getName(), keyEquivalence,
558 >        this(keyStrength.getName(), keyEquivalence,
559               valueStrength.getName(), valueEquivalence,
560               expectedSize);
561      }
# Line 600 | Line 601 | public class CustomConcurrentHashMap<K,
601                         Equivalence<? super KeyType> keyEquivalence,
602                         int expectedSize) {
603          return new CustomConcurrentHashMap<KeyType, Integer>
604 <            (keyStrength.getName(), keyEquivalence, INT_STRING, EQUALS,
604 >            (keyStrength.getName(), keyEquivalence, INT_STRING, EQUALS,
605               expectedSize);
606      }
607  
# Line 614 | Line 615 | public class CustomConcurrentHashMap<K,
615      public static CustomConcurrentHashMap<Integer, Integer>
616          newIntKeyIntValueMap(int expectedSize) {
617          return new CustomConcurrentHashMap<Integer, Integer>
618 <            (INT_STRING, EQUALS, INT_STRING, EQUALS,
618 >            (INT_STRING, EQUALS, INT_STRING, EQUALS,
619               expectedSize);
620      }
621  
# Line 629 | Line 630 | public class CustomConcurrentHashMap<K,
630  
631      /**
632       * Returns the segment for possibly inserting into the table
633 <     * associated with given hash, constructing it if necesary.
633 >     * associated with given hash, constructing it if necessary.
634       * @param hash the hash code for the key
635       * @return the segment
636       */
# Line 662 | Line 663 | public class CustomConcurrentHashMap<K,
663                  while (p != null) {
664                      Object k = p.get();
665                      if (k == key ||
666 <                        (k != null &&
667 <                         p.getLocator() == hash &&
666 >                        (k != null &&
667 >                         p.getLocator() == hash &&
668                           keyEquivalence.equal((K)k, key)))
669                          return p;
670                      p = p.getLinkage();
# Line 696 | Line 697 | public class CustomConcurrentHashMap<K,
697       * if no such mapping exists
698       *
699       * @param  key   possible key
700 <     * @return the value associated with the kew or <tt>null</tt> if
700 >     * @return the value associated with the key or <tt>null</tt> if
701       * there is no mapping.
702       * @throws NullPointerException if the specified key is null
703       */
# Line 712 | Line 713 | public class CustomConcurrentHashMap<K,
713      }
714  
715      /**
716 <     * Share dimplementation for put, putIfAbsent
716 >     * Shared implementation for put, putIfAbsent
717       */
718      final V doPut(K key, V value, boolean onlyIfNull) {
719          if (key == null || value == null)
# Line 824 | Line 825 | public class CustomConcurrentHashMap<K,
825                  Node r = findNode(key, hash, seg);
826                  if (r != null) {
827                      V v = (V)(r.getValue());
828 <                    if (v == oldValue ||
828 >                    if (v == oldValue ||
829                          (v != null && valueEquivalence.equal(v, oldValue))) {
830                          r.setValue(newValue);
831                          replaced = true;
# Line 864 | Line 865 | public class CustomConcurrentHashMap<K,
865                          Object k = p.get();
866                          if (k == key ||
867                              (k != null &&
868 <                             p.getLocator() == hash &&
868 >                             p.getLocator() == hash &&
869                               keyEquivalence.equal((K)k, key))) {
870                              oldValue = (V)(p.getValue());
871                              if (pred == null)
872 <                                tab[i] = n;
872 >                                tab[i] = n;
873                              else
874                                  pred.setLinkage(n);
875                              seg.decrementCount();
# Line 911 | Line 912 | public class CustomConcurrentHashMap<K,
912                          Object k = p.get();
913                          if (k == key ||
914                              (k != null &&
915 <                             p.getLocator() == hash &&
915 >                             p.getLocator() == hash &&
916                               keyEquivalence.equal((K)k, key))) {
917                              V v = (V)(p.getValue());
918                              if (v == value ||
919 <                                (v != null &&
919 >                                (v != null &&
920                                   valueEquivalence.equal(v, value))) {
921                                  if (pred == null)
922 <                                    tab[i] = n;
922 >                                    tab[i] = n;
923                                  else
924                                      pred.setLinkage(n);
925                                  seg.decrementCount();
# Line 956 | Line 957 | public class CustomConcurrentHashMap<K,
957                          Node n = p.getLinkage();
958                          if (p.get() != null && p.getValue() != null) {
959                              if (pred == null)
960 <                                tab[i] = n;
960 >                                tab[i] = n;
961                              else
962                                  pred.setLinkage(n);
963                              seg.decrementCount();
# Line 983 | Line 984 | public class CustomConcurrentHashMap<K,
984          final Segment[] segs = this.segments;
985          for (int i = 0; i < segs.length; ++i) {
986              Segment seg = segs[i];
987 <            if (seg != null &&
988 <                seg.getTableForTraversal() != null &&
987 >            if (seg != null &&
988 >                seg.getTableForTraversal() != null &&
989                  seg.count != 0)
990                  return false;
991          }
# Line 1030 | Line 1031 | public class CustomConcurrentHashMap<K,
1031              Node[] tab;
1032              if (seg != null && (tab = seg.getTableForTraversal()) != null) {
1033                  for (int j = 0; j < tab.length; ++j) {
1034 <                    for (Node p = tab[j];
1035 <                         p != null;
1034 >                    for (Node p = tab[j];
1035 >                         p != null;
1036                           p = p.getLinkage()) {
1037                          V v = (V)(p.getValue());
1038                          if (v == value ||
# Line 1078 | Line 1079 | public class CustomConcurrentHashMap<K,
1079       * </pre>
1080       *
1081       * except that the action is performed atomically.  Some
1082 <     * attemmpted operations on this map by other threads may be
1082 >     * attempted operations on this map by other threads may be
1083       * blocked while computation is in progress. Because this function
1084       * is invoked within atomicity control, the computation should be
1085       * short and simple. The most common usage is to construct a new
# Line 1086 | Line 1087 | public class CustomConcurrentHashMap<K,
1087       *
1088       * @param key key with which the specified value is to be associated
1089       * @param mappingFunction the function to compute a value
1090 <     * @return the current (existing or computed) value associated with
1090 >     * @return the current (existing or computed) value associated with
1091       *         the specified key, or <tt>null</tt> if the computation
1092       *         returned <tt>null</tt>.
1093 <     * @throws NullPointerException if the specified key or mappingFunction
1093 >     * @throws NullPointerException if the specified key or mappingFunction
1094       *         is null,
1095       * @throws RuntimeException or Error if the mappingFunction does so,
1096       *         in which case the mapping is left unestablished.
# Line 1111 | Line 1112 | public class CustomConcurrentHashMap<K,
1112                      // Map is OK if function throws exception
1113                      v = mappingFunction.map(key);
1114                      if (v != null) {
1115 <                        if (r != null)
1115 >                        if (r != null)
1116                              r.setValue(v);
1117                          else {
1118                              Node[] tab = seg.getTableForAdd(this);
# Line 1144 | Line 1145 | public class CustomConcurrentHashMap<K,
1145       *   else
1146       *     return remove(key);
1147       * </pre>
1148 <     *
1149 <     * except that the action is performed atomically. Some attemmpted
1148 >     *
1149 >     * except that the action is performed atomically. Some attempted
1150       * operations on this map by other threads may be blocked while
1151       * computation is in progress.
1152       *
# Line 1161 | Line 1162 | public class CustomConcurrentHashMap<K,
1162       * @param key key with which the specified value is to be associated
1163       * @param remappingFunction the function to compute a value
1164       * @return the updated value or
1165 <     *         <tt>null</tt> if the computation returned <tt>null</tt>
1166 <     * @throws NullPointerException if the specified key or remappingFunction
1165 >     *         <tt>null</tt> if the computation returned <tt>null</tt>
1166 >     * @throws NullPointerException if the specified key or remappingFunction
1167       *         is null,
1168       * @throws RuntimeException or Error if the remappingFunction does so,
1169       *         in which case the mapping is left in its previous state
# Line 1183 | Line 1184 | public class CustomConcurrentHashMap<K,
1184                  K k = (K)(p.get());
1185                  if (k == key ||
1186                      (k != null &&
1187 <                     p.getLocator() == hash &&
1187 >                     p.getLocator() == hash &&
1188                       keyEquivalence.equal(k, key))) {
1189                      value = (V)(p.getValue());
1190                      break;
# Line 1193 | Line 1194 | public class CustomConcurrentHashMap<K,
1194              }
1195              value = remappingFunction.remap(key, value);
1196              if (p != null) {
1197 <                if (value != null)
1197 >                if (value != null)
1198                      p.setValue(value);
1199                  else {
1200                      Node n = p.getLinkage();
1201                      if (pred == null)
1202 <                        tab[i] = n;
1202 >                        tab[i] = n;
1203                      else
1204                          pred.setLinkage(n);
1205                      seg.decrementCount();
1206                  }
1207              }
1208              else if (value != null) {
1209 <                Node r =
1209 >                Node r =
1210                      factory.newNode(hash, key, value, this, tab[i]);
1211                  // Fences.preStoreFence(r);
1212                  // tab[i] = r;
# Line 1254 | Line 1255 | public class CustomConcurrentHashMap<K,
1255                  else if (nextSegmentIndex >= 0) {
1256                      Segment seg = segments[nextSegmentIndex--];
1257                      Node[] t;
1258 <                    if (seg != null &&
1258 >                    if (seg != null &&
1259                          (t = seg.getTableForTraversal()) != null) {
1260                          currentTable = t;
1261                          nextTableIndex = t.length - 1;
# Line 1287 | Line 1288 | public class CustomConcurrentHashMap<K,
1288          final Map.Entry<K,V> nextEntry() {
1289              if (nextNode == null)
1290                  throw new NoSuchElementException();
1291 <            WriteThroughEntry e = new WriteThroughEntry((K)nextKey,
1291 >            WriteThroughEntry e = new WriteThroughEntry((K)nextKey,
1292                                                          (V)nextValue);
1293              advance();
1294              return e;
# Line 1330 | Line 1331 | public class CustomConcurrentHashMap<K,
1331          }
1332      }
1333  
1334 <    final class KeyIterator extends HashIterator
1334 >    final class KeyIterator extends HashIterator
1335          implements Iterator<K> {
1336 <        public K next() {
1337 <            return super.nextKey();
1336 >        public K next() {
1337 >            return super.nextKey();
1338          }
1339      }
1340  
# Line 1341 | Line 1342 | public class CustomConcurrentHashMap<K,
1342          return new KeyIterator();
1343      }
1344  
1345 <    final class ValueIterator extends HashIterator
1345 >    final class ValueIterator extends HashIterator
1346          implements Iterator<V> {
1347 <        public V next() {
1348 <            return super.nextValue();
1347 >        public V next() {
1348 >            return super.nextValue();
1349          }
1350      }
1351  
1352 <    final class EntryIterator extends HashIterator
1352 >    final class EntryIterator extends HashIterator
1353          implements Iterator<Map.Entry<K,V>> {
1354          public Map.Entry<K,V> next() {
1355              return super.nextEntry();
# Line 1403 | Line 1404 | public class CustomConcurrentHashMap<K,
1404                  return false;
1405              Map.Entry<?,?> e = (Map.Entry<?,?>)o;
1406              V v = CustomConcurrentHashMap.this.get(e.getKey());
1407 <            return v != null &&
1407 >            return v != null &&
1408                  valueEquivalence.equal(v, e.getValue());
1409          }
1410          public boolean remove(Object o) {
# Line 1501 | Line 1502 | public class CustomConcurrentHashMap<K,
1502      public boolean equals(Object o) {
1503          if (o == this)
1504              return true;
1505 <            
1505 >
1506          if (!(o instanceof Map))
1507              return false;
1508          Map<K,V> m = (Map<K,V>) o;
# Line 1602 | Line 1603 | public class CustomConcurrentHashMap<K,
1603           * that will be held in the set. If no estimate is known, zero
1604           * is an acceptable value.
1605           */
1606 <        public KeySet(Strength strength,
1606 >        public KeySet(Strength strength,
1607                        Equivalence<? super K> equivalence,
1608                        int expectedSize) {
1609              this.cchm = new CustomConcurrentHashMap<K,K>
1610 <                (strength.getName(), equivalence,
1610 >                (strength.getName(), equivalence,
1611                   SELF_STRING, equivalence, expectedSize);
1612          }
1613  
# Line 1614 | Line 1615 | public class CustomConcurrentHashMap<K,
1615           * Returns an element equivalent to the given element with
1616           * respect to this set's Equivalence, if such an element
1617           * exists, else adds and returns the given element.
1618 <         *
1618 >         *
1619           * @param e the element
1620           * @return e, or an element equivalent to e.
1621           */
1622          public K intern(K e) {
1623              K oldElement = cchm.doPut(e, e, true);
1624 <            return (oldElement != null) ? oldElement : e;
1624 >            return (oldElement != null) ? oldElement : e;
1625          }
1626 <        
1626 >
1627          /**
1628           * Returns <tt>true</tt> if this set contains an
1629           * element equivalent to the given element with respect
# Line 1633 | Line 1634 | public class CustomConcurrentHashMap<K,
1634          public boolean contains(Object o) {
1635              return cchm.containsKey(o);
1636          }
1637 <        
1637 >
1638          /**
1639           * Returns a <i>weakly consistent iterator</i> over the
1640           * elements in this set, that may reflect some, all or none of
# Line 1644 | Line 1645 | public class CustomConcurrentHashMap<K,
1645          public Iterator<K> iterator() {
1646              return cchm.keyIterator();
1647          }
1648 <        
1648 >
1649          /**
1650           * Adds the specified element to this set if there is not
1651           * already an element equivalent to the given element with
# Line 1686 | Line 1687 | public class CustomConcurrentHashMap<K,
1687          public int size() {
1688              return cchm.size();
1689          }
1690 <        
1690 >
1691          /**
1692           * Removes all of the elements from this set.
1693           */
# Line 1749 | Line 1750 | public class CustomConcurrentHashMap<K,
1750                      Reference<?> r = q.remove();
1751                      if (r instanceof Reclaimable)
1752                          ((Reclaimable)r).onReclamation();
1753 <                } catch (InterruptedException e) {
1754 <                    /* ignore */
1753 >                } catch (InterruptedException e) {
1754 >                    /* ignore */
1755                  }
1756              }
1757          }
# Line 1758 | Line 1759 | public class CustomConcurrentHashMap<K,
1759  
1760      // classes extending Weak/soft refs embedded in reclaimable nodes
1761  
1762 <    static class EmbeddedWeakReference extends WeakReference
1762 >    static class EmbeddedWeakReference extends WeakReference
1763          implements Reclaimable {
1764          final Reclaimable outer;
1765          EmbeddedWeakReference(Object x, Reclaimable outer) {
1766              super(x, getReclamationQueue());
1767              this.outer = outer;
1768          }
1769 <        public final void onReclamation() {
1769 >        public final void onReclamation() {
1770              clear();
1771 <            outer.onReclamation();
1771 >            outer.onReclamation();
1772          }
1773      }
1774  
1775 <    static class EmbeddedSoftReference extends SoftReference
1775 >    static class EmbeddedSoftReference extends SoftReference
1776          implements Reclaimable {
1777          final Reclaimable outer;
1778          EmbeddedSoftReference(Object x, Reclaimable outer) {
1779              super(x, getReclamationQueue());
1780              this.outer = outer;
1781          }
1782 <        public final void onReclamation() {
1782 >        public final void onReclamation() {
1783              clear();
1784 <            outer.onReclamation();
1784 >            outer.onReclamation();
1785          }
1786      }
1787  
# Line 1800 | Line 1801 | public class CustomConcurrentHashMap<K,
1801      }
1802  
1803  
1804 <    static abstract class StrongKeySelfValueNode
1804 >    static abstract class StrongKeySelfValueNode
1805          extends StrongKeyNode {
1806          StrongKeySelfValueNode(int locator, Object key) {
1807              super(locator, key);
# Line 1810 | Line 1811 | public class CustomConcurrentHashMap<K,
1811          public final void onReclamation() { }
1812      }
1813  
1814 <    static final class TerminalStrongKeySelfValueNode
1814 >    static final class TerminalStrongKeySelfValueNode
1815          extends StrongKeySelfValueNode {
1816          TerminalStrongKeySelfValueNode(int locator, Object key) {
1817              super(locator, key);
# Line 1819 | Line 1820 | public class CustomConcurrentHashMap<K,
1820          public final void setLinkage(Node r) { }
1821      }
1822  
1823 <    static final class LinkedStrongKeySelfValueNode
1823 >    static final class LinkedStrongKeySelfValueNode
1824          extends StrongKeySelfValueNode {
1825          volatile Node linkage;
1826 <        LinkedStrongKeySelfValueNode(int locator, Object key,
1826 >        LinkedStrongKeySelfValueNode(int locator, Object key,
1827                                       Node linkage) {
1828              super(locator, key);
1829              this.linkage = linkage;
# Line 1835 | Line 1836 | public class CustomConcurrentHashMap<K,
1836          implements NodeFactory, Serializable {
1837          private static final long serialVersionUID = 7249069346764182397L;
1838          public final Node newNode(int locator,
1839 <                                  Object key, Object value,
1839 >                                  Object key, Object value,
1840                                    CustomConcurrentHashMap cchm,
1841                                    Node linkage) {
1842              if (linkage == null)
# Line 1845 | Line 1846 | public class CustomConcurrentHashMap<K,
1846                  return new LinkedStrongKeySelfValueNode
1847                      (locator, key, linkage);
1848          }
1849 <    }        
1849 >    }
1850  
1851 <    static abstract class StrongKeyStrongValueNode
1851 >    static abstract class StrongKeyStrongValueNode
1852          extends StrongKeyNode {
1853          volatile Object value;
1854          StrongKeyStrongValueNode(int locator, Object key, Object value) {
# Line 1859 | Line 1860 | public class CustomConcurrentHashMap<K,
1860          public final void onReclamation() { }
1861      }
1862  
1863 <    static final class TerminalStrongKeyStrongValueNode
1863 >    static final class TerminalStrongKeyStrongValueNode
1864          extends StrongKeyStrongValueNode {
1865          TerminalStrongKeyStrongValueNode(int locator,
1866                                           Object key, Object value) {
# Line 1869 | Line 1870 | public class CustomConcurrentHashMap<K,
1870          public final void setLinkage(Node r) { }
1871      }
1872  
1873 <    static final class LinkedStrongKeyStrongValueNode
1873 >    static final class LinkedStrongKeyStrongValueNode
1874          extends StrongKeyStrongValueNode {
1875          volatile Node linkage;
1876          LinkedStrongKeyStrongValueNode(int locator,
1877 <                                       Object key, Object value,
1877 >                                       Object key, Object value,
1878                                         Node linkage) {
1879              super(locator, key, value);
1880              this.linkage = linkage;
# Line 1882 | Line 1883 | public class CustomConcurrentHashMap<K,
1883          public final void setLinkage(Node r) { linkage = r; }
1884      }
1885  
1886 <    static final class StrongKeyStrongValueNodeFactory
1886 >    static final class StrongKeyStrongValueNodeFactory
1887          implements NodeFactory, Serializable {
1888          private static final long serialVersionUID = 7249069346764182397L;
1889          public final Node newNode(int locator,
1890 <                                  Object key, Object value,
1890 >                                  Object key, Object value,
1891                                    CustomConcurrentHashMap cchm,
1892                                    Node linkage) {
1893              if (linkage == null)
# Line 1896 | Line 1897 | public class CustomConcurrentHashMap<K,
1897                  return new LinkedStrongKeyStrongValueNode
1898                      (locator, key, value, linkage);
1899          }
1900 <    }        
1900 >    }
1901  
1902      // ...
1903  
1904 <    static abstract class StrongKeyIntValueNode
1904 >    static abstract class StrongKeyIntValueNode
1905          extends StrongKeyNode {
1906          volatile int value;
1907          StrongKeyIntValueNode(int locator, Object key, Object value) {
# Line 1908 | Line 1909 | public class CustomConcurrentHashMap<K,
1909              this.value = ((Integer)value).intValue();
1910          }
1911          public final Object getValue() { return Integer.valueOf(value); }
1912 <        public final void setValue(Object value) {
1912 >        public final void setValue(Object value) {
1913              this.value = ((Integer)value).intValue();
1914          }
1915          public final void onReclamation() { }
1916      }
1917  
1918 <    static final class TerminalStrongKeyIntValueNode
1918 >    static final class TerminalStrongKeyIntValueNode
1919          extends StrongKeyIntValueNode {
1920          TerminalStrongKeyIntValueNode(int locator,
1921                                           Object key, Object value) {
# Line 1924 | Line 1925 | public class CustomConcurrentHashMap<K,
1925          public final void setLinkage(Node r) { }
1926      }
1927  
1928 <    static final class LinkedStrongKeyIntValueNode
1928 >    static final class LinkedStrongKeyIntValueNode
1929          extends StrongKeyIntValueNode {
1930          volatile Node linkage;
1931          LinkedStrongKeyIntValueNode(int locator,
1932 <                                       Object key, Object value,
1932 >                                       Object key, Object value,
1933                                         Node linkage) {
1934              super(locator, key, value);
1935              this.linkage = linkage;
# Line 1937 | Line 1938 | public class CustomConcurrentHashMap<K,
1938          public final void setLinkage(Node r) { linkage = r; }
1939      }
1940  
1941 <    static final class StrongKeyIntValueNodeFactory
1941 >    static final class StrongKeyIntValueNodeFactory
1942          implements NodeFactory, Serializable {
1943          private static final long serialVersionUID = 7249069346764182397L;
1944          public final Node newNode(int locator,
1945 <                                  Object key, Object value,
1945 >                                  Object key, Object value,
1946                                    CustomConcurrentHashMap cchm,
1947                                    Node linkage) {
1948              if (linkage == null)
# Line 1951 | Line 1952 | public class CustomConcurrentHashMap<K,
1952                  return new LinkedStrongKeyIntValueNode
1953                      (locator, key, value, linkage);
1954          }
1955 <    }        
1955 >    }
1956  
1957      // ...
1958  
1959 <    static abstract class StrongKeyWeakValueNode
1959 >    static abstract class StrongKeyWeakValueNode
1960          extends StrongKeyNode {
1961          volatile EmbeddedWeakReference valueRef;
1962          final CustomConcurrentHashMap cchm;
1963 <        StrongKeyWeakValueNode(int locator, Object key, Object value,
1963 >        StrongKeyWeakValueNode(int locator, Object key, Object value,
1964                                 CustomConcurrentHashMap cchm) {
1965              super(locator, key);
1966              this.cchm = cchm;
# Line 1981 | Line 1982 | public class CustomConcurrentHashMap<K,
1982          }
1983      }
1984  
1985 <    static final class TerminalStrongKeyWeakValueNode
1985 >    static final class TerminalStrongKeyWeakValueNode
1986          extends StrongKeyWeakValueNode {
1987          TerminalStrongKeyWeakValueNode(int locator,
1988 <                                       Object key, Object value,
1988 >                                       Object key, Object value,
1989                                         CustomConcurrentHashMap cchm) {
1990              super(locator, key, value, cchm);
1991          }
# Line 1992 | Line 1993 | public class CustomConcurrentHashMap<K,
1993          public final void setLinkage(Node r) { }
1994      }
1995  
1996 <    static final class LinkedStrongKeyWeakValueNode
1996 >    static final class LinkedStrongKeyWeakValueNode
1997          extends StrongKeyWeakValueNode {
1998          volatile Node linkage;
1999          LinkedStrongKeyWeakValueNode(int locator,
2000 <                                     Object key, Object value,
2000 >                                     Object key, Object value,
2001                                       CustomConcurrentHashMap cchm,
2002                                       Node linkage) {
2003              super(locator, key, value, cchm);
# Line 2006 | Line 2007 | public class CustomConcurrentHashMap<K,
2007          public final void setLinkage(Node r) { linkage = r; }
2008      }
2009  
2010 <    static final class StrongKeyWeakValueNodeFactory
2010 >    static final class StrongKeyWeakValueNodeFactory
2011          implements NodeFactory, Serializable {
2012          private static final long serialVersionUID = 7249069346764182397L;
2013 <        public final Node newNode(int locator,
2014 <                                  Object key, Object value,
2013 >        public final Node newNode(int locator,
2014 >                                  Object key, Object value,
2015                                    CustomConcurrentHashMap cchm,
2016                                    Node linkage) {
2017              if (linkage == null)
# Line 2020 | Line 2021 | public class CustomConcurrentHashMap<K,
2021                  return new LinkedStrongKeyWeakValueNode
2022                      (locator, key, value, cchm, linkage);
2023          }
2024 <    }        
2024 >    }
2025  
2026  
2027 <    static abstract class StrongKeySoftValueNode
2027 >    static abstract class StrongKeySoftValueNode
2028          extends StrongKeyNode {
2029          volatile EmbeddedSoftReference valueRef;
2030          final CustomConcurrentHashMap cchm;
2031 <        StrongKeySoftValueNode(int locator, Object key, Object value,
2031 >        StrongKeySoftValueNode(int locator, Object key, Object value,
2032                                 CustomConcurrentHashMap cchm) {
2033              super(locator, key);
2034              this.cchm = cchm;
# Line 2049 | Line 2050 | public class CustomConcurrentHashMap<K,
2050          }
2051      }
2052  
2053 <    static final class TerminalStrongKeySoftValueNode
2053 >    static final class TerminalStrongKeySoftValueNode
2054          extends StrongKeySoftValueNode {
2055          TerminalStrongKeySoftValueNode(int locator,
2056 <                                       Object key, Object value,
2056 >                                       Object key, Object value,
2057                                         CustomConcurrentHashMap cchm) {
2058              super(locator, key, value, cchm);
2059          }
# Line 2060 | Line 2061 | public class CustomConcurrentHashMap<K,
2061          public final void setLinkage(Node r) { }
2062      }
2063  
2064 <    static final class LinkedStrongKeySoftValueNode
2064 >    static final class LinkedStrongKeySoftValueNode
2065          extends StrongKeySoftValueNode {
2066          volatile Node linkage;
2067          LinkedStrongKeySoftValueNode(int locator,
2068 <                                     Object key, Object value,
2068 >                                     Object key, Object value,
2069                                       CustomConcurrentHashMap cchm,
2070                                       Node linkage) {
2071              super(locator, key, value, cchm);
# Line 2074 | Line 2075 | public class CustomConcurrentHashMap<K,
2075          public final void setLinkage(Node r) { linkage = r; }
2076      }
2077  
2078 <    static final class StrongKeySoftValueNodeFactory
2078 >    static final class StrongKeySoftValueNodeFactory
2079          implements NodeFactory, Serializable {
2080          private static final long serialVersionUID = 7249069346764182397L;
2081 <        public final Node newNode(int locator,
2082 <                                  Object key, Object value,
2081 >        public final Node newNode(int locator,
2082 >                                  Object key, Object value,
2083                                    CustomConcurrentHashMap cchm,
2084                                    Node linkage) {
2085              if (linkage == null)
# Line 2088 | Line 2089 | public class CustomConcurrentHashMap<K,
2089                  return new LinkedStrongKeySoftValueNode
2090                      (locator, key, value, cchm, linkage);
2091          }
2092 <    }        
2092 >    }
2093  
2094      // Weak keys
2095  
# Line 2102 | Line 2103 | public class CustomConcurrentHashMap<K,
2103              this.cchm = cchm;
2104          }
2105          public final int getLocator() { return locator; }
2106 <        public final void onReclamation() {
2106 >        public final void onReclamation() {
2107              clear();
2108              cchm.removeIfReclaimed(this);
2109          }
2110      }
2111  
2112 <    static abstract class WeakKeySelfValueNode
2112 >    static abstract class WeakKeySelfValueNode
2113          extends WeakKeyNode {
2114          WeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2115              super(locator, key, cchm);
# Line 2117 | Line 2118 | public class CustomConcurrentHashMap<K,
2118          public final void setValue(Object value) { }
2119      }
2120  
2121 <    static final class TerminalWeakKeySelfValueNode
2121 >    static final class TerminalWeakKeySelfValueNode
2122          extends WeakKeySelfValueNode {
2123          TerminalWeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2124              super(locator, key, cchm);
# Line 2126 | Line 2127 | public class CustomConcurrentHashMap<K,
2127          public final void setLinkage(Node r) { }
2128      }
2129  
2130 <    static final class LinkedWeakKeySelfValueNode
2130 >    static final class LinkedWeakKeySelfValueNode
2131          extends WeakKeySelfValueNode {
2132          volatile Node linkage;
2133          LinkedWeakKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm,
# Line 2142 | Line 2143 | public class CustomConcurrentHashMap<K,
2143          implements NodeFactory, Serializable {
2144          private static final long serialVersionUID = 7249069346764182397L;
2145          public final Node newNode(int locator,
2146 <                                  Object key, Object value,
2146 >                                  Object key, Object value,
2147                                    CustomConcurrentHashMap cchm,
2148                                    Node linkage) {
2149              if (linkage == null)
# Line 2152 | Line 2153 | public class CustomConcurrentHashMap<K,
2153                  return new LinkedWeakKeySelfValueNode
2154                      (locator, key, cchm, linkage);
2155          }
2156 <    }        
2156 >    }
2157  
2158  
2159 <    static abstract class WeakKeyStrongValueNode
2159 >    static abstract class WeakKeyStrongValueNode
2160          extends WeakKeyNode {
2161          volatile Object value;
2162          WeakKeyStrongValueNode(int locator, Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2166 | Line 2167 | public class CustomConcurrentHashMap<K,
2167          public final void setValue(Object value) { this.value = value; }
2168      }
2169  
2170 <    static final class TerminalWeakKeyStrongValueNode
2170 >    static final class TerminalWeakKeyStrongValueNode
2171          extends WeakKeyStrongValueNode {
2172          TerminalWeakKeyStrongValueNode(int locator,
2173                                         Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2176 | Line 2177 | public class CustomConcurrentHashMap<K,
2177          public final void setLinkage(Node r) { }
2178      }
2179  
2180 <    static final class LinkedWeakKeyStrongValueNode
2180 >    static final class LinkedWeakKeyStrongValueNode
2181          extends WeakKeyStrongValueNode {
2182          volatile Node linkage;
2183          LinkedWeakKeyStrongValueNode(int locator,
# Line 2189 | Line 2190 | public class CustomConcurrentHashMap<K,
2190          public final void setLinkage(Node r) { linkage = r; }
2191      }
2192  
2193 <    static final class WeakKeyStrongValueNodeFactory
2193 >    static final class WeakKeyStrongValueNodeFactory
2194          implements NodeFactory, Serializable {
2195          private static final long serialVersionUID = 7249069346764182397L;
2196          public final Node newNode(int locator,
2197 <                                  Object key, Object value,
2197 >                                  Object key, Object value,
2198                                    CustomConcurrentHashMap cchm,
2199                                    Node linkage) {
2200              if (linkage == null)
# Line 2203 | Line 2204 | public class CustomConcurrentHashMap<K,
2204                  return new LinkedWeakKeyStrongValueNode
2205                      (locator, key, value, cchm, linkage);
2206          }
2207 <    }        
2207 >    }
2208  
2209 <    static abstract class WeakKeyIntValueNode
2209 >    static abstract class WeakKeyIntValueNode
2210          extends WeakKeyNode {
2211          volatile int value;
2212          WeakKeyIntValueNode(int locator, Object key, Object value,
# Line 2214 | Line 2215 | public class CustomConcurrentHashMap<K,
2215              this.value = ((Integer)value).intValue();
2216          }
2217          public final Object getValue() { return Integer.valueOf(value); }
2218 <        public final void setValue(Object value) {
2218 >        public final void setValue(Object value) {
2219              this.value = ((Integer)value).intValue();
2220          }
2221      }
2222  
2223 <    static final class TerminalWeakKeyIntValueNode
2223 >    static final class TerminalWeakKeyIntValueNode
2224          extends WeakKeyIntValueNode {
2225          TerminalWeakKeyIntValueNode(int locator,
2226                                      Object key, Object value,
# Line 2230 | Line 2231 | public class CustomConcurrentHashMap<K,
2231          public final void setLinkage(Node r) { }
2232      }
2233  
2234 <    static final class LinkedWeakKeyIntValueNode
2234 >    static final class LinkedWeakKeyIntValueNode
2235          extends WeakKeyIntValueNode {
2236          volatile Node linkage;
2237          LinkedWeakKeyIntValueNode(int locator,
2238 <                                  Object key, Object value,
2238 >                                  Object key, Object value,
2239                                    CustomConcurrentHashMap cchm,
2240                                    Node linkage) {
2241              super(locator, key, value, cchm);
# Line 2244 | Line 2245 | public class CustomConcurrentHashMap<K,
2245          public final void setLinkage(Node r) { linkage = r; }
2246      }
2247  
2248 <    static final class WeakKeyIntValueNodeFactory
2248 >    static final class WeakKeyIntValueNodeFactory
2249          implements NodeFactory, Serializable {
2250          private static final long serialVersionUID = 7249069346764182397L;
2251          public final Node newNode(int locator,
2252 <                                  Object key, Object value,
2252 >                                  Object key, Object value,
2253                                    CustomConcurrentHashMap cchm,
2254                                    Node linkage) {
2255              if (linkage == null)
# Line 2258 | Line 2259 | public class CustomConcurrentHashMap<K,
2259                  return new LinkedWeakKeyIntValueNode
2260                      (locator, key, value, cchm, linkage);
2261          }
2262 <    }        
2262 >    }
2263  
2264 <    static abstract class WeakKeyWeakValueNode
2264 >    static abstract class WeakKeyWeakValueNode
2265          extends WeakKeyNode {
2266          volatile EmbeddedWeakReference valueRef;
2267 <        WeakKeyWeakValueNode(int locator, Object key, Object value,
2267 >        WeakKeyWeakValueNode(int locator, Object key, Object value,
2268                               CustomConcurrentHashMap cchm) {
2269              super(locator, key, cchm);
2270              if (value != null)
# Line 2281 | Line 2282 | public class CustomConcurrentHashMap<K,
2282          }
2283      }
2284  
2285 <    static final class TerminalWeakKeyWeakValueNode
2285 >    static final class TerminalWeakKeyWeakValueNode
2286          extends WeakKeyWeakValueNode {
2287          TerminalWeakKeyWeakValueNode(int locator,
2288 <                                     Object key, Object value,
2288 >                                     Object key, Object value,
2289                                       CustomConcurrentHashMap cchm) {
2290              super(locator, key, value, cchm);
2291          }
# Line 2292 | Line 2293 | public class CustomConcurrentHashMap<K,
2293          public final void setLinkage(Node r) { }
2294      }
2295  
2296 <    static final class LinkedWeakKeyWeakValueNode
2296 >    static final class LinkedWeakKeyWeakValueNode
2297          extends WeakKeyWeakValueNode {
2298          volatile Node linkage;
2299          LinkedWeakKeyWeakValueNode(int locator,
2300 <                                   Object key, Object value,
2300 >                                   Object key, Object value,
2301                                     CustomConcurrentHashMap cchm,
2302                                     Node linkage) {
2303              super(locator, key, value, cchm);
# Line 2306 | Line 2307 | public class CustomConcurrentHashMap<K,
2307          public final void setLinkage(Node r) { linkage = r; }
2308      }
2309  
2310 <    static final class WeakKeyWeakValueNodeFactory
2310 >    static final class WeakKeyWeakValueNodeFactory
2311          implements NodeFactory, Serializable {
2312          private static final long serialVersionUID = 7249069346764182397L;
2313 <        public final Node newNode(int locator,
2314 <                                  Object key, Object value,
2313 >        public final Node newNode(int locator,
2314 >                                  Object key, Object value,
2315                                    CustomConcurrentHashMap cchm,
2316                                    Node linkage) {
2317              if (linkage == null)
# Line 2320 | Line 2321 | public class CustomConcurrentHashMap<K,
2321                  return new LinkedWeakKeyWeakValueNode
2322                      (locator, key, value, cchm, linkage);
2323          }
2324 <    }        
2324 >    }
2325  
2326  
2327 <    static abstract class WeakKeySoftValueNode
2327 >    static abstract class WeakKeySoftValueNode
2328          extends WeakKeyNode {
2329          volatile EmbeddedSoftReference valueRef;
2330 <        WeakKeySoftValueNode(int locator, Object key, Object value,
2330 >        WeakKeySoftValueNode(int locator, Object key, Object value,
2331                               CustomConcurrentHashMap cchm) {
2332              super(locator, key, cchm);
2333              if (value != null)
# Line 2344 | Line 2345 | public class CustomConcurrentHashMap<K,
2345          }
2346      }
2347  
2348 <    static final class TerminalWeakKeySoftValueNode
2348 >    static final class TerminalWeakKeySoftValueNode
2349          extends WeakKeySoftValueNode {
2350          TerminalWeakKeySoftValueNode(int locator,
2351 <                                     Object key, Object value,
2351 >                                     Object key, Object value,
2352                                       CustomConcurrentHashMap cchm) {
2353              super(locator, key, value, cchm);
2354          }
# Line 2355 | Line 2356 | public class CustomConcurrentHashMap<K,
2356          public final void setLinkage(Node r) { }
2357      }
2358  
2359 <    static final class LinkedWeakKeySoftValueNode
2359 >    static final class LinkedWeakKeySoftValueNode
2360          extends WeakKeySoftValueNode {
2361          volatile Node linkage;
2362          LinkedWeakKeySoftValueNode(int locator,
2363 <                                   Object key, Object value,
2363 >                                   Object key, Object value,
2364                                     CustomConcurrentHashMap cchm,
2365                                     Node linkage) {
2366              super(locator, key, value, cchm);
# Line 2369 | Line 2370 | public class CustomConcurrentHashMap<K,
2370          public final void setLinkage(Node r) { linkage = r; }
2371      }
2372  
2373 <    static final class WeakKeySoftValueNodeFactory
2373 >    static final class WeakKeySoftValueNodeFactory
2374          implements NodeFactory, Serializable {
2375          private static final long serialVersionUID = 7249069346764182397L;
2376 <        public final Node newNode(int locator,
2377 <                                  Object key, Object value,
2376 >        public final Node newNode(int locator,
2377 >                                  Object key, Object value,
2378                                    CustomConcurrentHashMap cchm,
2379                                    Node linkage) {
2380              if (linkage == null)
# Line 2383 | Line 2384 | public class CustomConcurrentHashMap<K,
2384                  return new LinkedWeakKeySoftValueNode
2385                      (locator, key, value, cchm, linkage);
2386          }
2387 <    }        
2387 >    }
2388  
2389      // Soft keys
2390  
# Line 2397 | Line 2398 | public class CustomConcurrentHashMap<K,
2398              this.cchm = cchm;
2399          }
2400          public final int getLocator() { return locator; }
2401 <        public final void onReclamation() {
2401 >        public final void onReclamation() {
2402              clear();
2403              cchm.removeIfReclaimed(this);
2404          }
2405      }
2406  
2407 <    static abstract class SoftKeySelfValueNode
2407 >    static abstract class SoftKeySelfValueNode
2408          extends SoftKeyNode {
2409          SoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2410              super(locator, key, cchm);
# Line 2412 | Line 2413 | public class CustomConcurrentHashMap<K,
2413          public final void setValue(Object value) { }
2414      }
2415  
2416 <    static final class TerminalSoftKeySelfValueNode
2416 >    static final class TerminalSoftKeySelfValueNode
2417          extends SoftKeySelfValueNode {
2418          TerminalSoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm) {
2419              super(locator, key, cchm);
# Line 2421 | Line 2422 | public class CustomConcurrentHashMap<K,
2422          public final void setLinkage(Node r) { }
2423      }
2424  
2425 <    static final class LinkedSoftKeySelfValueNode
2425 >    static final class LinkedSoftKeySelfValueNode
2426          extends SoftKeySelfValueNode {
2427          volatile Node linkage;
2428          LinkedSoftKeySelfValueNode(int locator, Object key, CustomConcurrentHashMap cchm,
# Line 2437 | Line 2438 | public class CustomConcurrentHashMap<K,
2438          implements NodeFactory, Serializable {
2439          private static final long serialVersionUID = 7249069346764182397L;
2440          public final Node newNode(int locator,
2441 <                                  Object key, Object value,
2441 >                                  Object key, Object value,
2442                                    CustomConcurrentHashMap cchm,
2443                                    Node linkage) {
2444              if (linkage == null)
# Line 2447 | Line 2448 | public class CustomConcurrentHashMap<K,
2448                  return new LinkedSoftKeySelfValueNode
2449                      (locator, key, cchm, linkage);
2450          }
2451 <    }        
2451 >    }
2452  
2453  
2454 <    static abstract class SoftKeyStrongValueNode
2454 >    static abstract class SoftKeyStrongValueNode
2455          extends SoftKeyNode {
2456          volatile Object value;
2457          SoftKeyStrongValueNode(int locator, Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2461 | Line 2462 | public class CustomConcurrentHashMap<K,
2462          public final void setValue(Object value) { this.value = value; }
2463      }
2464  
2465 <    static final class TerminalSoftKeyStrongValueNode
2465 >    static final class TerminalSoftKeyStrongValueNode
2466          extends SoftKeyStrongValueNode {
2467          TerminalSoftKeyStrongValueNode(int locator,
2468                                         Object key, Object value, CustomConcurrentHashMap cchm) {
# Line 2471 | Line 2472 | public class CustomConcurrentHashMap<K,
2472          public final void setLinkage(Node r) { }
2473      }
2474  
2475 <    static final class LinkedSoftKeyStrongValueNode
2475 >    static final class LinkedSoftKeyStrongValueNode
2476          extends SoftKeyStrongValueNode {
2477          volatile Node linkage;
2478          LinkedSoftKeyStrongValueNode(int locator,
# Line 2484 | Line 2485 | public class CustomConcurrentHashMap<K,
2485          public final void setLinkage(Node r) { linkage = r; }
2486      }
2487  
2488 <    static final class SoftKeyStrongValueNodeFactory
2488 >    static final class SoftKeyStrongValueNodeFactory
2489          implements NodeFactory, Serializable {
2490          private static final long serialVersionUID = 7249069346764182397L;
2491          public final Node newNode(int locator,
2492 <                                  Object key, Object value,
2492 >                                  Object key, Object value,
2493                                    CustomConcurrentHashMap cchm,
2494                                    Node linkage) {
2495              if (linkage == null)
# Line 2498 | Line 2499 | public class CustomConcurrentHashMap<K,
2499                  return new LinkedSoftKeyStrongValueNode
2500                      (locator, key, value, cchm, linkage);
2501          }
2502 <    }        
2502 >    }
2503  
2504 <    static abstract class SoftKeyIntValueNode
2504 >    static abstract class SoftKeyIntValueNode
2505          extends SoftKeyNode {
2506          volatile int value;
2507          SoftKeyIntValueNode(int locator, Object key, Object value,
# Line 2509 | Line 2510 | public class CustomConcurrentHashMap<K,
2510              this.value = ((Integer)value).intValue();
2511          }
2512          public final Object getValue() { return Integer.valueOf(value); }
2513 <        public final void setValue(Object value) {
2513 >        public final void setValue(Object value) {
2514              this.value = ((Integer)value).intValue();
2515          }
2516      }
2517  
2518 <    static final class TerminalSoftKeyIntValueNode
2518 >    static final class TerminalSoftKeyIntValueNode
2519          extends SoftKeyIntValueNode {
2520          TerminalSoftKeyIntValueNode(int locator,
2521                                      Object key, Object value,
# Line 2525 | Line 2526 | public class CustomConcurrentHashMap<K,
2526          public final void setLinkage(Node r) { }
2527      }
2528  
2529 <    static final class LinkedSoftKeyIntValueNode
2529 >    static final class LinkedSoftKeyIntValueNode
2530          extends SoftKeyIntValueNode {
2531          volatile Node linkage;
2532          LinkedSoftKeyIntValueNode(int locator,
2533 <                                  Object key, Object value,
2533 >                                  Object key, Object value,
2534                                    CustomConcurrentHashMap cchm,
2535                                    Node linkage) {
2536              super(locator, key, value, cchm);
# Line 2539 | Line 2540 | public class CustomConcurrentHashMap<K,
2540          public final void setLinkage(Node r) { linkage = r; }
2541      }
2542  
2543 <    static final class SoftKeyIntValueNodeFactory
2543 >    static final class SoftKeyIntValueNodeFactory
2544          implements NodeFactory, Serializable {
2545          private static final long serialVersionUID = 7249069346764182397L;
2546          public final Node newNode(int locator,
2547 <                                  Object key, Object value,
2547 >                                  Object key, Object value,
2548                                    CustomConcurrentHashMap cchm,
2549                                    Node linkage) {
2550              if (linkage == null)
# Line 2553 | Line 2554 | public class CustomConcurrentHashMap<K,
2554                  return new LinkedSoftKeyIntValueNode
2555                      (locator, key, value, cchm, linkage);
2556          }
2557 <    }        
2557 >    }
2558  
2559 <    static abstract class SoftKeyWeakValueNode
2559 >    static abstract class SoftKeyWeakValueNode
2560          extends SoftKeyNode {
2561          volatile EmbeddedWeakReference valueRef;
2562 <        SoftKeyWeakValueNode(int locator, Object key, Object value,
2562 >        SoftKeyWeakValueNode(int locator, Object key, Object value,
2563                               CustomConcurrentHashMap cchm) {
2564              super(locator, key, cchm);
2565              if (value != null)
# Line 2576 | Line 2577 | public class CustomConcurrentHashMap<K,
2577          }
2578      }
2579  
2580 <    static final class TerminalSoftKeyWeakValueNode
2580 >    static final class TerminalSoftKeyWeakValueNode
2581          extends SoftKeyWeakValueNode {
2582          TerminalSoftKeyWeakValueNode(int locator,
2583 <                                     Object key, Object value,
2583 >                                     Object key, Object value,
2584                                       CustomConcurrentHashMap cchm) {
2585              super(locator, key, value, cchm);
2586          }
# Line 2587 | Line 2588 | public class CustomConcurrentHashMap<K,
2588          public final void setLinkage(Node r) { }
2589      }
2590  
2591 <    static final class LinkedSoftKeyWeakValueNode
2591 >    static final class LinkedSoftKeyWeakValueNode
2592          extends SoftKeyWeakValueNode {
2593          volatile Node linkage;
2594          LinkedSoftKeyWeakValueNode(int locator,
2595 <                                   Object key, Object value,
2595 >                                   Object key, Object value,
2596                                     CustomConcurrentHashMap cchm,
2597                                     Node linkage) {
2598              super(locator, key, value, cchm);
# Line 2601 | Line 2602 | public class CustomConcurrentHashMap<K,
2602          public final void setLinkage(Node r) { linkage = r; }
2603      }
2604  
2605 <    static final class SoftKeyWeakValueNodeFactory
2605 >    static final class SoftKeyWeakValueNodeFactory
2606          implements NodeFactory, Serializable {
2607          private static final long serialVersionUID = 7249069346764182397L;
2608 <        public final Node newNode(int locator,
2609 <                                  Object key, Object value,
2608 >        public final Node newNode(int locator,
2609 >                                  Object key, Object value,
2610                                    CustomConcurrentHashMap cchm,
2611                                    Node linkage) {
2612              if (linkage == null)
# Line 2615 | Line 2616 | public class CustomConcurrentHashMap<K,
2616                  return new LinkedSoftKeyWeakValueNode
2617                      (locator, key, value, cchm, linkage);
2618          }
2619 <    }        
2619 >    }
2620  
2621  
2622 <    static abstract class SoftKeySoftValueNode
2622 >    static abstract class SoftKeySoftValueNode
2623          extends SoftKeyNode {
2624          volatile EmbeddedSoftReference valueRef;
2625 <        SoftKeySoftValueNode(int locator, Object key, Object value,
2625 >        SoftKeySoftValueNode(int locator, Object key, Object value,
2626                               CustomConcurrentHashMap cchm) {
2627              super(locator, key, cchm);
2628              if (value != null)
# Line 2639 | Line 2640 | public class CustomConcurrentHashMap<K,
2640          }
2641      }
2642  
2643 <    static final class TerminalSoftKeySoftValueNode
2643 >    static final class TerminalSoftKeySoftValueNode
2644          extends SoftKeySoftValueNode {
2645          TerminalSoftKeySoftValueNode(int locator,
2646 <                                     Object key, Object value,
2646 >                                     Object key, Object value,
2647                                       CustomConcurrentHashMap cchm) {
2648              super(locator, key, value, cchm);
2649          }
# Line 2650 | Line 2651 | public class CustomConcurrentHashMap<K,
2651          public final void setLinkage(Node r) { }
2652      }
2653  
2654 <    static final class LinkedSoftKeySoftValueNode
2654 >    static final class LinkedSoftKeySoftValueNode
2655          extends SoftKeySoftValueNode {
2656          volatile Node linkage;
2657          LinkedSoftKeySoftValueNode(int locator,
2658 <                                   Object key, Object value,
2658 >                                   Object key, Object value,
2659                                     CustomConcurrentHashMap cchm,
2660                                     Node linkage) {
2661              super(locator, key, value, cchm);
# Line 2664 | Line 2665 | public class CustomConcurrentHashMap<K,
2665          public final void setLinkage(Node r) { linkage = r; }
2666      }
2667  
2668 <    static final class SoftKeySoftValueNodeFactory
2668 >    static final class SoftKeySoftValueNodeFactory
2669          implements NodeFactory, Serializable {
2670          private static final long serialVersionUID = 7249069346764182397L;
2671 <        public final Node newNode(int locator,
2672 <                                  Object key, Object value,
2671 >        public final Node newNode(int locator,
2672 >                                  Object key, Object value,
2673                                    CustomConcurrentHashMap cchm,
2674                                    Node linkage) {
2675              if (linkage == null)
# Line 2678 | Line 2679 | public class CustomConcurrentHashMap<K,
2679                  return new LinkedSoftKeySoftValueNode
2680                      (locator, key, value, cchm, linkage);
2681          }
2682 <    }        
2682 >    }
2683  
2684      static abstract class IntKeyNode implements Node {
2685          final int key;
# Line 2690 | Line 2691 | public class CustomConcurrentHashMap<K,
2691      }
2692  
2693  
2694 <    static abstract class IntKeySelfValueNode
2694 >    static abstract class IntKeySelfValueNode
2695          extends IntKeyNode {
2696          IntKeySelfValueNode(int locator, Object key) {
2697              super(locator, key);
# Line 2700 | Line 2701 | public class CustomConcurrentHashMap<K,
2701          public final void onReclamation() { }
2702      }
2703  
2704 <    static final class TerminalIntKeySelfValueNode
2704 >    static final class TerminalIntKeySelfValueNode
2705          extends IntKeySelfValueNode {
2706          TerminalIntKeySelfValueNode(int locator, Object key) {
2707              super(locator, key);
# Line 2709 | Line 2710 | public class CustomConcurrentHashMap<K,
2710          public final void setLinkage(Node r) { }
2711      }
2712  
2713 <    static final class LinkedIntKeySelfValueNode
2713 >    static final class LinkedIntKeySelfValueNode
2714          extends IntKeySelfValueNode {
2715          volatile Node linkage;
2716 <        LinkedIntKeySelfValueNode(int locator, Object key,
2716 >        LinkedIntKeySelfValueNode(int locator, Object key,
2717                                       Node linkage) {
2718              super(locator, key);
2719              this.linkage = linkage;
# Line 2725 | Line 2726 | public class CustomConcurrentHashMap<K,
2726          implements NodeFactory, Serializable {
2727          private static final long serialVersionUID = 7249069346764182397L;
2728          public final Node newNode(int locator,
2729 <                                  Object key, Object value,
2729 >                                  Object key, Object value,
2730                                    CustomConcurrentHashMap cchm,
2731                                    Node linkage) {
2732              if (linkage == null)
# Line 2735 | Line 2736 | public class CustomConcurrentHashMap<K,
2736                  return new LinkedIntKeySelfValueNode
2737                      (locator, key, linkage);
2738          }
2739 <    }        
2739 >    }
2740  
2741 <    static abstract class IntKeyStrongValueNode
2741 >    static abstract class IntKeyStrongValueNode
2742          extends IntKeyNode {
2743          volatile Object value;
2744          IntKeyStrongValueNode(int locator, Object key, Object value) {
# Line 2749 | Line 2750 | public class CustomConcurrentHashMap<K,
2750          public final void onReclamation() { }
2751      }
2752  
2753 <    static final class TerminalIntKeyStrongValueNode
2753 >    static final class TerminalIntKeyStrongValueNode
2754          extends IntKeyStrongValueNode {
2755          TerminalIntKeyStrongValueNode(int locator,
2756                                           Object key, Object value) {
# Line 2759 | Line 2760 | public class CustomConcurrentHashMap<K,
2760          public final void setLinkage(Node r) { }
2761      }
2762  
2763 <    static final class LinkedIntKeyStrongValueNode
2763 >    static final class LinkedIntKeyStrongValueNode
2764          extends IntKeyStrongValueNode {
2765          volatile Node linkage;
2766          LinkedIntKeyStrongValueNode(int locator,
2767 <                                       Object key, Object value,
2767 >                                       Object key, Object value,
2768                                         Node linkage) {
2769              super(locator, key, value);
2770              this.linkage = linkage;
# Line 2772 | Line 2773 | public class CustomConcurrentHashMap<K,
2773          public final void setLinkage(Node r) { linkage = r; }
2774      }
2775  
2776 <    static final class IntKeyStrongValueNodeFactory
2776 >    static final class IntKeyStrongValueNodeFactory
2777          implements NodeFactory, Serializable {
2778          private static final long serialVersionUID = 7249069346764182397L;
2779          public final Node newNode(int locator,
2780 <                                  Object key, Object value,
2780 >                                  Object key, Object value,
2781                                    CustomConcurrentHashMap cchm,
2782                                    Node linkage) {
2783              if (linkage == null)
# Line 2786 | Line 2787 | public class CustomConcurrentHashMap<K,
2787                  return new LinkedIntKeyStrongValueNode
2788                      (locator, key, value, linkage);
2789          }
2790 <    }        
2790 >    }
2791  
2792 <    static abstract class IntKeyIntValueNode
2792 >    static abstract class IntKeyIntValueNode
2793          extends IntKeyNode {
2794          volatile int value;
2795          IntKeyIntValueNode(int locator, Object key, Object value) {
# Line 2796 | Line 2797 | public class CustomConcurrentHashMap<K,
2797              this.value = ((Integer)value).intValue();
2798          }
2799          public final Object getValue() { return Integer.valueOf(value); }
2800 <        public final void setValue(Object value) {
2800 >        public final void setValue(Object value) {
2801              this.value = ((Integer)value).intValue();
2802          }
2803          public final void onReclamation() { }
2804      }
2805  
2806 <    static final class TerminalIntKeyIntValueNode
2806 >    static final class TerminalIntKeyIntValueNode
2807          extends IntKeyIntValueNode {
2808          TerminalIntKeyIntValueNode(int locator,
2809                                           Object key, Object value) {
# Line 2812 | Line 2813 | public class CustomConcurrentHashMap<K,
2813          public final void setLinkage(Node r) { }
2814      }
2815  
2816 <    static final class LinkedIntKeyIntValueNode
2816 >    static final class LinkedIntKeyIntValueNode
2817          extends IntKeyIntValueNode {
2818          volatile Node linkage;
2819          LinkedIntKeyIntValueNode(int locator,
2820 <                                       Object key, Object value,
2820 >                                       Object key, Object value,
2821                                         Node linkage) {
2822              super(locator, key, value);
2823              this.linkage = linkage;
# Line 2825 | Line 2826 | public class CustomConcurrentHashMap<K,
2826          public final void setLinkage(Node r) { linkage = r; }
2827      }
2828  
2829 <    static final class IntKeyIntValueNodeFactory
2829 >    static final class IntKeyIntValueNodeFactory
2830          implements NodeFactory, Serializable {
2831          private static final long serialVersionUID = 7249069346764182397L;
2832          public final Node newNode(int locator,
2833 <                                  Object key, Object value,
2833 >                                  Object key, Object value,
2834                                    CustomConcurrentHashMap cchm,
2835                                    Node linkage) {
2836              if (linkage == null)
# Line 2839 | Line 2840 | public class CustomConcurrentHashMap<K,
2840                  return new LinkedIntKeyIntValueNode
2841                      (locator, key, value, linkage);
2842          }
2843 <    }        
2843 >    }
2844  
2845 <    static abstract class IntKeyWeakValueNode
2845 >    static abstract class IntKeyWeakValueNode
2846          extends IntKeyNode {
2847          volatile EmbeddedWeakReference valueRef;
2848          final CustomConcurrentHashMap cchm;
2849 <        IntKeyWeakValueNode(int locator, Object key, Object value,
2849 >        IntKeyWeakValueNode(int locator, Object key, Object value,
2850                                 CustomConcurrentHashMap cchm) {
2851              super(locator, key);
2852              this.cchm = cchm;
# Line 2867 | Line 2868 | public class CustomConcurrentHashMap<K,
2868          }
2869      }
2870  
2871 <    static final class TerminalIntKeyWeakValueNode
2871 >    static final class TerminalIntKeyWeakValueNode
2872          extends IntKeyWeakValueNode {
2873          TerminalIntKeyWeakValueNode(int locator,
2874 <                                       Object key, Object value,
2874 >                                       Object key, Object value,
2875                                         CustomConcurrentHashMap cchm) {
2876              super(locator, key, value, cchm);
2877          }
# Line 2878 | Line 2879 | public class CustomConcurrentHashMap<K,
2879          public final void setLinkage(Node r) { }
2880      }
2881  
2882 <    static final class LinkedIntKeyWeakValueNode
2882 >    static final class LinkedIntKeyWeakValueNode
2883          extends IntKeyWeakValueNode {
2884          volatile Node linkage;
2885          LinkedIntKeyWeakValueNode(int locator,
2886 <                                     Object key, Object value,
2886 >                                     Object key, Object value,
2887                                       CustomConcurrentHashMap cchm,
2888                                       Node linkage) {
2889              super(locator, key, value, cchm);
# Line 2892 | Line 2893 | public class CustomConcurrentHashMap<K,
2893          public final void setLinkage(Node r) { linkage = r; }
2894      }
2895  
2896 <    static final class IntKeyWeakValueNodeFactory
2896 >    static final class IntKeyWeakValueNodeFactory
2897          implements NodeFactory, Serializable {
2898          private static final long serialVersionUID = 7249069346764182397L;
2899 <        public final Node newNode(int locator,
2900 <                                  Object key, Object value,
2899 >        public final Node newNode(int locator,
2900 >                                  Object key, Object value,
2901                                    CustomConcurrentHashMap cchm,
2902                                    Node linkage) {
2903              if (linkage == null)
# Line 2906 | Line 2907 | public class CustomConcurrentHashMap<K,
2907                  return new LinkedIntKeyWeakValueNode
2908                      (locator, key, value, cchm, linkage);
2909          }
2910 <    }        
2910 >    }
2911  
2912  
2913 <    static abstract class IntKeySoftValueNode
2913 >    static abstract class IntKeySoftValueNode
2914          extends IntKeyNode {
2915          volatile EmbeddedSoftReference valueRef;
2916          final CustomConcurrentHashMap cchm;
2917 <        IntKeySoftValueNode(int locator, Object key, Object value,
2917 >        IntKeySoftValueNode(int locator, Object key, Object value,
2918                                 CustomConcurrentHashMap cchm) {
2919              super(locator, key);
2920              this.cchm = cchm;
# Line 2935 | Line 2936 | public class CustomConcurrentHashMap<K,
2936          }
2937      }
2938  
2939 <    static final class TerminalIntKeySoftValueNode
2939 >    static final class TerminalIntKeySoftValueNode
2940          extends IntKeySoftValueNode {
2941          TerminalIntKeySoftValueNode(int locator,
2942 <                                       Object key, Object value,
2942 >                                       Object key, Object value,
2943                                         CustomConcurrentHashMap cchm) {
2944              super(locator, key, value, cchm);
2945          }
# Line 2946 | Line 2947 | public class CustomConcurrentHashMap<K,
2947          public final void setLinkage(Node r) { }
2948      }
2949  
2950 <    static final class LinkedIntKeySoftValueNode
2950 >    static final class LinkedIntKeySoftValueNode
2951          extends IntKeySoftValueNode {
2952          volatile Node linkage;
2953          LinkedIntKeySoftValueNode(int locator,
2954 <                                     Object key, Object value,
2954 >                                     Object key, Object value,
2955                                       CustomConcurrentHashMap cchm,
2956                                       Node linkage) {
2957              super(locator, key, value, cchm);
# Line 2960 | Line 2961 | public class CustomConcurrentHashMap<K,
2961          public final void setLinkage(Node r) { linkage = r; }
2962      }
2963  
2964 <    static final class IntKeySoftValueNodeFactory
2964 >    static final class IntKeySoftValueNodeFactory
2965          implements NodeFactory, Serializable {
2966          private static final long serialVersionUID = 7249069346764182397L;
2967 <        public final Node newNode(int locator,
2968 <                                  Object key, Object value,
2967 >        public final Node newNode(int locator,
2968 >                                  Object key, Object value,
2969                                    CustomConcurrentHashMap cchm,
2970                                    Node linkage) {
2971              if (linkage == null)
# Line 2974 | Line 2975 | public class CustomConcurrentHashMap<K,
2975                  return new LinkedIntKeySoftValueNode
2976                      (locator, key, value, cchm, linkage);
2977          }
2978 <    }        
2978 >    }
2979  
2980  
2981  
# Line 3028 | Line 3029 | public class CustomConcurrentHashMap<K,
3029      }
3030  
3031      // Fenced store into segment table array. Unneeded when we have Fences
3032 <    static final  void storeNode(Node[] table,
3032 >    static final  void storeNode(Node[] table,
3033                                   int i, Node r) {
3034 <        _unsafe.putOrderedObject(table, (i << tableShift) + tableBase, r);
3034 >        long nodeOffset = ((long) i << tableShift) + tableBase;
3035 >        _unsafe.putOrderedObject(table, nodeOffset, r);
3036      }
3037  
3038 <    static final  void storeSegment(Segment[] segs,
3038 >    static final  void storeSegment(Segment[] segs,
3039                                      int i, Segment s) {
3040 <        _unsafe.putOrderedObject(segs, (i << segmentsShift) + segmentsBase, s);
3040 >        long segmentOffset = ((long) i << segmentsShift) + segmentsBase;
3041 >        _unsafe.putOrderedObject(segs, segmentOffset, s);
3042      }
3043  
3044  
3045   }
3043

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines