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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines