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

Comparing jsr166/src/jsr166e/ConcurrentHashMapV8.java (file contents):
Revision 1.102 by dl, Wed Jun 19 14:55:40 2013 UTC vs.
Revision 1.108 by jsr166, Mon Jul 1 19:19:31 2013 UTC

# Line 228 | Line 228 | public class ConcurrentHashMapV8<K,V>
228       * java.util.Spliterator.
229       */
230      public static interface ConcurrentHashMapSpliterator<T> {
231 <        /**
231 >        /**
232           * If possible, returns a new spliterator covering
233           * approximately one half of the elements, which will not be
234           * covered by this spliterator. Returns null if cannot be
# Line 299 | Line 299 | public class ConcurrentHashMapV8<K,V>
299       * because they have negative hash fields and null key and value
300       * fields. (These special nodes are either uncommon or transient,
301       * so the impact of carrying around some unused fields is
302 <     * insignficant.)
302 >     * insignificant.)
303       *
304       * The table is lazily initialized to a power-of-two size upon the
305       * first insertion.  Each bin in the table normally contains a
# Line 462 | Line 462 | public class ConcurrentHashMapV8<K,V>
462       *
463       * TreeBins also require an additional locking mechanism.  While
464       * list traversal is always possible by readers even during
465 <     * updates, tree traversal is not, mainly beause of tree-rotations
465 >     * updates, tree traversal is not, mainly because of tree-rotations
466       * that may change the root node and/or its linkages.  TreeBins
467       * include a simple read-write lock mechanism parasitic on the
468       * main bin-synchronization strategy: Structural adjustments
# Line 569 | Line 569 | public class ConcurrentHashMapV8<K,V>
569       * Encodings for Node hash fields. See above for explanation.
570       */
571      static final int MOVED     = 0x8fffffff; // (-1) hash for forwarding nodes
572 <    static final int TREEBIN   = 0x80000000; // hash for heads of treea
572 >    static final int TREEBIN   = 0x80000000; // hash for roots of trees
573      static final int RESERVED  = 0x80000001; // hash for transient reservations
574      static final int HASH_BITS = 0x7fffffff; // usable bits of normal node hash
575  
# Line 589 | Line 589 | public class ConcurrentHashMapV8<K,V>
589       * Key-value entry.  This class is never exported out as a
590       * user-mutable Map.Entry (i.e., one supporting setValue; see
591       * MapEntry below), but can be used for read-only traversals used
592 <     * in bulk tasks.  Subclasses of Node with a negativehash field
592 >     * in bulk tasks.  Subclasses of Node with a negative hash field
593       * are special, and contain null keys and values (but are never
594       * exported).  Otherwise, keys and vals are never null.
595       */
# Line 735 | Line 735 | public class ConcurrentHashMapV8<K,V>
735                                          Node<K,V> c, Node<K,V> v) {
736          return U.compareAndSwapObject(tab, ((long)i << ASHIFT) + ABASE, c, v);
737      }
738 <    
738 >
739      static final <K,V> void setTabAt(Node<K,V>[] tab, int i, Node<K,V> v) {
740          U.putOrderedObject(tab, ((long)i << ASHIFT) + ABASE, v);
741      }
742 <    
742 >
743      /* ---------------- Fields -------------- */
744  
745      /**
# Line 2422 | Line 2422 | public class ConcurrentHashMapV8<K,V>
2422                                      ++hc;
2423                                  }
2424                              }
2425 <                            ln = (lc <= UNTREEIFY_THRESHOLD ?  untreeify(lo) :
2426 <                                  (hc != 0) ? new TreeBin<K,V>(lo) : t);
2427 <                            hn = (hc <= UNTREEIFY_THRESHOLD ? untreeify(hi) :
2428 <                                  (lc != 0) ? new TreeBin<K,V>(hi) : t);
2425 >                            ln = (lc <= UNTREEIFY_THRESHOLD) ? untreeify(lo) :
2426 >                                (hc != 0) ? new TreeBin<K,V>(lo) : t;
2427 >                            hn = (hc <= UNTREEIFY_THRESHOLD) ? untreeify(hi) :
2428 >                                (lc != 0) ? new TreeBin<K,V>(hi) : t;
2429                          }
2430                          else
2431                              ln = hn = null;
# Line 2475 | Line 2475 | public class ConcurrentHashMapV8<K,V>
2475      }
2476  
2477      /**
2478 <     * Returns a list on non-TreeNodes replacing those in given list
2478 >     * Returns a list on non-TreeNodes replacing those in given list.
2479       */
2480      static <K,V> Node<K,V> untreeify(Node<K,V> b) {
2481          Node<K,V> hd = null, tl = null;
# Line 2530 | Line 2530 | public class ConcurrentHashMapV8<K,V>
2530                          return p;
2531                      else if (pl == null && pr == null)
2532                          break;
2533 <                    else if ((kc != null ||
2533 >                    else if ((kc != null ||
2534                                (kc = comparableClassFor(k)) != null) &&
2535                               (dir = compareComparables(kc, k, pk)) != 0)
2536                          p = (dir < 0) ? pl : pr;
2537                      else if (pl == null)
2538                          p = pr;
2539 <                    else if (pr == null ||
2539 >                    else if (pr == null ||
2540                               (q = pr.findTreeNode(h, k, kc)) == null)
2541                          p = pl;
2542                      else
# Line 2613 | Line 2613 | public class ConcurrentHashMapV8<K,V>
2613          }
2614  
2615          /**
2616 <         * Acquires write lock for tree restructuring
2616 >         * Acquires write lock for tree restructuring.
2617           */
2618          private final void lockRoot() {
2619              if (!U.compareAndSwapInt(this, LOCKSTATE, 0, WRITER))
# Line 2621 | Line 2621 | public class ConcurrentHashMapV8<K,V>
2621          }
2622  
2623          /**
2624 <         * Releases write lock for tree restructuring
2624 >         * Releases write lock for tree restructuring.
2625           */
2626          private final void unlockRoot() {
2627              lockState = 0;
2628          }
2629  
2630          /**
2631 <         * Possibly blocks awaiting root lock
2631 >         * Possibly blocks awaiting root lock.
2632           */
2633          private final void contendedLock() {
2634              boolean waiting = false;
# Line 2653 | Line 2653 | public class ConcurrentHashMapV8<K,V>
2653  
2654          /**
2655           * Returns matching node or null if none. Tries to search
2656 <         * using tree compareisons from root, but continues linear
2656 >         * using tree comparisons from root, but continues linear
2657           * search when lock not available.
2658           */
2659          final Node<K,V> find(int h, Object k) {
# Line 2751 | Line 2751 | public class ConcurrentHashMapV8<K,V>
2751           * that are accessible independently of lock. So instead we
2752           * swap the tree linkages.
2753           *
2754 <         * @return true if now too small so should be untreeified.
2754 >         * @return true if now too small, so should be untreeified
2755           */
2756          final boolean removeTreeNode(TreeNode<K,V> p) {
2757              TreeNode<K,V> next = (TreeNode<K,V>)p.next;
# Line 3034 | Line 3034 | public class ConcurrentHashMapV8<K,V>
3034                  }
3035              }
3036          }
3037 +
3038          /**
3039           * Recursive invariant check
3040           */
# Line 3145 | Line 3146 | public class ConcurrentHashMapV8<K,V>
3146  
3147      /**
3148       * Base of key, value, and entry Iterators. Adds fields to
3149 <     * Traverser to support iterator.remove
3149 >     * Traverser to support iterator.remove.
3150       */
3151      static class BaseIterator<K,V> extends Traverser<K,V> {
3152          final ConcurrentHashMapV8<K,V> map;
# Line 3497 | Line 3498 | public class ConcurrentHashMapV8<K,V>
3498       * of all (key, value) pairs
3499       * @since 1.8
3500       */
3501 <    public double reduceToDoubleIn(long parallelismThreshold,
3502 <                                   ObjectByObjectToDouble<? super K, ? super V> transformer,
3503 <                                   double basis,
3504 <                                   DoubleByDoubleToDouble reducer) {
3501 >    public double reduceToDouble(long parallelismThreshold,
3502 >                                 ObjectByObjectToDouble<? super K, ? super V> transformer,
3503 >                                 double basis,
3504 >                                 DoubleByDoubleToDouble reducer) {
3505          if (transformer == null || reducer == null)
3506              throw new NullPointerException();
3507          return new MapReduceMappingsToDoubleTask<K,V>
# Line 5985 | Line 5986 | public class ConcurrentHashMapV8<K,V>
5986      }
5987  
5988      /**
5989 <     * Generates initial value for per-thread CounterHashCodes
5989 >     * Generates initial value for per-thread CounterHashCodes.
5990       */
5991      static final AtomicInteger counterHashCodeGenerator = new AtomicInteger();
5992  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines