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.61 by dl, Thu Sep 13 10:41:37 2012 UTC vs.
Revision 1.70 by dl, Sun Oct 28 22:35:45 2012 UTC

# Line 8 | Line 8 | package jsr166e;
8   import jsr166e.LongAdder;
9   import jsr166e.ForkJoinPool;
10   import jsr166e.ForkJoinTask;
11
11   import java.util.Comparator;
12   import java.util.Arrays;
13   import java.util.Map;
# Line 85 | Line 84 | import java.io.Serializable;
84   * {@code hashCode()} is a sure way to slow down performance of any
85   * hash table.
86   *
87 + * <p> A {@link Set} projection of a ConcurrentHashMap may be created
88 + * (using {@link #newKeySet()} or {@link #newKeySet(int)}), or viewed
89 + * (using {@link #keySet(Object)} when only keys are of interest, and the
90 + * mapped values are (perhaps transiently) not used or all take the
91 + * same mapping value.
92 + *
93 + * <p> A ConcurrentHashMapV8 can be used as scalable frequency map (a
94 + * form of histogram or multiset) by using {@link LongAdder} values
95 + * and initializing via {@link #computeIfAbsent}. For example, to add
96 + * a count to a {@code ConcurrentHashMapV8<String,LongAdder> freqs}, you
97 + * can use {@code freqs.computeIfAbsent(k -> new
98 + * LongAdder()).increment();}
99 + *
100   * <p>This class and its views and iterators implement all of the
101   * <em>optional</em> methods of the {@link Map} and {@link Iterator}
102   * interfaces.
# Line 92 | Line 104 | import java.io.Serializable;
104   * <p> Like {@link Hashtable} but unlike {@link HashMap}, this class
105   * does <em>not</em> allow {@code null} to be used as a key or value.
106   *
107 + * <p>ConcurrentHashMapV8s support parallel operations using the {@link
108 + * ForkJoinPool#commonPool}. (Task that may be used in other contexts
109 + * are available in class {@link ForkJoinTasks}). These operations are
110 + * designed to be safely, and often sensibly, applied even with maps
111 + * that are being concurrently updated by other threads; for example,
112 + * when computing a snapshot summary of the values in a shared
113 + * registry.  There are three kinds of operation, each with four
114 + * forms, accepting functions with Keys, Values, Entries, and (Key,
115 + * Value) arguments and/or return values. Because the elements of a
116 + * ConcurrentHashMapV8 are not ordered in any particular way, and may be
117 + * processed in different orders in different parallel executions, the
118 + * correctness of supplied functions should not depend on any
119 + * ordering, or on any other objects or values that may transiently
120 + * change while computation is in progress; and except for forEach
121 + * actions, should ideally be side-effect-free.
122 + *
123 + * <ul>
124 + * <li> forEach: Perform a given action on each element.
125 + * A variant form applies a given transformation on each element
126 + * before performing the action.</li>
127 + *
128 + * <li> search: Return the first available non-null result of
129 + * applying a given function on each element; skipping further
130 + * search when a result is found.</li>
131 + *
132 + * <li> reduce: Accumulate each element.  The supplied reduction
133 + * function cannot rely on ordering (more formally, it should be
134 + * both associative and commutative).  There are five variants:
135 + *
136 + * <ul>
137 + *
138 + * <li> Plain reductions. (There is not a form of this method for
139 + * (key, value) function arguments since there is no corresponding
140 + * return type.)</li>
141 + *
142 + * <li> Mapped reductions that accumulate the results of a given
143 + * function applied to each element.</li>
144 + *
145 + * <li> Reductions to scalar doubles, longs, and ints, using a
146 + * given basis value.</li>
147 + *
148 + * </li>
149 + * </ul>
150 + * </ul>
151 + *
152 + * <p>The concurrency properties of bulk operations follow
153 + * from those of ConcurrentHashMapV8: Any non-null result returned
154 + * from {@code get(key)} and related access methods bears a
155 + * happens-before relation with the associated insertion or
156 + * update.  The result of any bulk operation reflects the
157 + * composition of these per-element relations (but is not
158 + * necessarily atomic with respect to the map as a whole unless it
159 + * is somehow known to be quiescent).  Conversely, because keys
160 + * and values in the map are never null, null serves as a reliable
161 + * atomic indicator of the current lack of any result.  To
162 + * maintain this property, null serves as an implicit basis for
163 + * all non-scalar reduction operations. For the double, long, and
164 + * int versions, the basis should be one that, when combined with
165 + * any other value, returns that other value (more formally, it
166 + * should be the identity element for the reduction). Most common
167 + * reductions have these properties; for example, computing a sum
168 + * with basis 0 or a minimum with basis MAX_VALUE.
169 + *
170 + * <p>Search and transformation functions provided as arguments
171 + * should similarly return null to indicate the lack of any result
172 + * (in which case it is not used). In the case of mapped
173 + * reductions, this also enables transformations to serve as
174 + * filters, returning null (or, in the case of primitive
175 + * specializations, the identity basis) if the element should not
176 + * be combined. You can create compound transformations and
177 + * filterings by composing them yourself under this "null means
178 + * there is nothing there now" rule before using them in search or
179 + * reduce operations.
180 + *
181 + * <p>Methods accepting and/or returning Entry arguments maintain
182 + * key-value associations. They may be useful for example when
183 + * finding the key for the greatest value. Note that "plain" Entry
184 + * arguments can be supplied using {@code new
185 + * AbstractMap.SimpleEntry(k,v)}.
186 + *
187 + * <p> Bulk operations may complete abruptly, throwing an
188 + * exception encountered in the application of a supplied
189 + * function. Bear in mind when handling such exceptions that other
190 + * concurrently executing functions could also have thrown
191 + * exceptions, or would have done so if the first exception had
192 + * not occurred.
193 + *
194 + * <p>Parallel speedups for bulk operations compared to sequential
195 + * processing are common but not guaranteed.  Operations involving
196 + * brief functions on small maps may execute more slowly than
197 + * sequential loops if the underlying work to parallelize the
198 + * computation is more expensive than the computation
199 + * itself. Similarly, parallelization may not lead to much actual
200 + * parallelism if all processors are busy performing unrelated tasks.
201 + *
202 + * <p> All arguments to all task methods must be non-null.
203 + *
204 + * <p><em>jsr166e note: During transition, this class
205 + * uses nested functional interfaces with different names but the
206 + * same forms as those expected for JDK8.<em>
207 + *
208   * <p>This class is a member of the
209   * <a href="{@docRoot}/../technotes/guides/collections/index.html">
210   * Java Collections Framework</a>.
211   *
99 * <p><em>jsr166e note: This class is a candidate replacement for
100 * java.util.concurrent.ConcurrentHashMap.  During transition, this
101 * class declares and uses nested functional interfaces with different
102 * names but the same forms as those expected for JDK8.<em>
103 *
212   * @since 1.5
213   * @author Doug Lea
214   * @param <K> the type of keys maintained by this map
# Line 179 | Line 287 | public class ConcurrentHashMapV8<K, V>
287          Spliterator<T> split();
288      }
289  
290 +    /**
291 +     * A view of a ConcurrentHashMapV8 as a {@link Set} of keys, in
292 +     * which additions may optionally be enabled by mapping to a
293 +     * common value.  This class cannot be directly instantiated. See
294 +     * {@link #keySet}, {@link #keySet(Object)}, {@link #newKeySet()},
295 +     * {@link #newKeySet(int)}.
296 +     *
297 +     * <p>The view's {@code iterator} is a "weakly consistent" iterator
298 +     * that will never throw {@link ConcurrentModificationException},
299 +     * and guarantees to traverse elements as they existed upon
300 +     * construction of the iterator, and may (but is not guaranteed to)
301 +     * reflect any modifications subsequent to construction.
302 +     */
303 +    public static class KeySetView<K,V> extends CHMView<K,V> implements Set<K>, java.io.Serializable {
304 +        private static final long serialVersionUID = 7249069246763182397L;
305 +        private final V value;
306 +        KeySetView(ConcurrentHashMapV8<K, V> map, V value) {  // non-public
307 +            super(map);
308 +            this.value = value;
309 +        }
310 +
311 +        /**
312 +         * Returns the map backing this view.
313 +         *
314 +         * @return the map backing this view
315 +         */
316 +        public ConcurrentHashMapV8<K,V> getMap() { return map; }
317 +
318 +        /**
319 +         * Returns the default mapped value for additions,
320 +         * or {@code null} if additions are not supported.
321 +         *
322 +         * @return the default mapped value for additions, or {@code null}
323 +         * if not supported.
324 +         */
325 +        public V getMappedValue() { return value; }
326 +
327 +        // implement Set API
328 +
329 +        public boolean contains(Object o) { return map.containsKey(o); }
330 +        public boolean remove(Object o)   { return map.remove(o) != null; }
331 +        public Iterator<K> iterator()     { return new KeyIterator<K,V>(map); }
332 +        public boolean add(K e) {
333 +            V v;
334 +            if ((v = value) == null)
335 +                throw new UnsupportedOperationException();
336 +            if (e == null)
337 +                throw new NullPointerException();
338 +            return map.internalPutIfAbsent(e, v) == null;
339 +        }
340 +        public boolean addAll(Collection<? extends K> c) {
341 +            boolean added = false;
342 +            V v;
343 +            if ((v = value) == null)
344 +                throw new UnsupportedOperationException();
345 +            for (K e : c) {
346 +                if (e == null)
347 +                    throw new NullPointerException();
348 +                if (map.internalPutIfAbsent(e, v) == null)
349 +                    added = true;
350 +            }
351 +            return added;
352 +        }
353 +        public boolean equals(Object o) {
354 +            Set<?> c;
355 +            return ((o instanceof Set) &&
356 +                    ((c = (Set<?>)o) == this ||
357 +                     (containsAll(c) && c.containsAll(this))));
358 +        }
359 +    }
360 +
361      /*
362       * Overview:
363       *
# Line 461 | Line 640 | public class ConcurrentHashMapV8<K, V>
640      private transient volatile int sizeCtl;
641  
642      // views
643 <    private transient KeySet<K,V> keySet;
643 >    private transient KeySetView<K,V> keySet;
644      private transient Values<K,V> values;
645      private transient EntrySet<K,V> entrySet;
646  
# Line 2243 | Line 2422 | public class ConcurrentHashMapV8<K, V>
2422       * change (including to null, indicating deletion), field nextVal
2423       * might not be accurate at point of use, but still maintains the
2424       * weak consistency property of holding a value that was once
2425 <     * valid.
2425 >     * valid. To support iterator.remove, the nextKey field is not
2426 >     * updated (nulled out) when the iterator cannot advance.
2427       *
2428       * Internal traversals directly access these fields, as in:
2429       * {@code while (it.advance() != null) { process(it.nextKey); }}
# Line 2280 | Line 2460 | public class ConcurrentHashMapV8<K, V>
2460      @SuppressWarnings("serial") static class Traverser<K,V,R> extends ForkJoinTask<R> {
2461          final ConcurrentHashMapV8<K, V> map;
2462          Node next;           // the next entry to use
2283        Node last;           // the last entry used
2463          Object nextKey;      // cached key field of next
2464          Object nextVal;      // cached val field of next
2465          Node[] tab;          // current table; updated if resized
2466          int index;           // index of bin to use next
2467          int baseIndex;       // current index of initial table
2468          int baseLimit;       // index bound for initial table
2469 <        final int baseSize;  // initial table size
2469 >        int baseSize;        // initial table size
2470  
2471          /** Creates iterator for all entries in the table. */
2472          Traverser(ConcurrentHashMapV8<K, V> map) {
2473 <            this.tab = (this.map = map).table;
2295 <            baseLimit = baseSize = (tab == null) ? 0 : tab.length;
2473 >            this.map = map;
2474          }
2475  
2476          /** Creates iterator for split() methods */
2477          Traverser(Traverser<K,V,?> it) {
2478 <            this.map = it.map;
2479 <            this.tab = it.tab;
2478 >            ConcurrentHashMapV8<K, V> m; Node[] t;
2479 >            if ((m = this.map = it.map) == null)
2480 >                t = null;
2481 >            else if ((t = it.tab) == null && // force parent tab initialization
2482 >                     (t = it.tab = m.table) != null)
2483 >                it.baseLimit = it.baseSize = t.length;
2484 >            this.tab = t;
2485              this.baseSize = it.baseSize;
2486              it.baseLimit = this.index = this.baseIndex =
2487                  ((this.baseLimit = it.baseLimit) + it.baseIndex + 1) >>> 1;
# Line 2309 | Line 2492 | public class ConcurrentHashMapV8<K, V>
2492           * See above for explanation.
2493           */
2494          final Object advance() {
2495 <            Node e = last = next;
2495 >            Node e = next;
2496              Object ev = null;
2497              outer: do {
2498                  if (e != null)                  // advance past used/skipped node
2499                      e = e.next;
2500                  while (e == null) {             // get to next non-null bin
2501 +                    ConcurrentHashMapV8<K, V> m;
2502                      Node[] t; int b, i, n; Object ek; // checks must use locals
2503 <                    if ((b = baseIndex) >= baseLimit || (i = index) < 0 ||
2504 <                        (t = tab) == null || i >= (n = t.length))
2503 >                    if ((t = tab) != null)
2504 >                        n = t.length;
2505 >                    else if ((m = map) != null && (t = tab = m.table) != null)
2506 >                        n = baseLimit = baseSize = t.length;
2507 >                    else
2508 >                        break outer;
2509 >                    if ((b = baseIndex) >= baseLimit ||
2510 >                        (i = index) < 0 || i >= n)
2511                          break outer;
2512 <                    else if ((e = tabAt(t, i)) != null && e.hash == MOVED) {
2512 >                    if ((e = tabAt(t, i)) != null && e.hash == MOVED) {
2513                          if ((ek = e.key) instanceof TreeBin)
2514                              e = ((TreeBin)ek).first;
2515                          else {
# Line 2336 | Line 2526 | public class ConcurrentHashMapV8<K, V>
2526          }
2527  
2528          public final void remove() {
2529 <            if (nextVal == null && last == null)
2530 <                advance();
2341 <            Node e = last;
2342 <            if (e == null)
2529 >            Object k = nextKey;
2530 >            if (k == null && (advance() == null || (k = nextKey) == null))
2531                  throw new IllegalStateException();
2532 <            last = null;
2345 <            map.remove(e.key);
2532 >            map.internalReplace(k, null, null);
2533          }
2534  
2535          public final boolean hasNext() {
# Line 2446 | Line 2633 | public class ConcurrentHashMapV8<K, V>
2633      }
2634  
2635      /**
2636 +     * Creates a new {@link Set} backed by a ConcurrentHashMapV8
2637 +     * from the given type to {@code Boolean.TRUE}.
2638 +     *
2639 +     * @return the new set
2640 +     */
2641 +    public static <K> KeySetView<K,Boolean> newKeySet() {
2642 +        return new KeySetView<K,Boolean>(new ConcurrentHashMapV8<K,Boolean>(),
2643 +                                      Boolean.TRUE);
2644 +    }
2645 +
2646 +    /**
2647 +     * Creates a new {@link Set} backed by a ConcurrentHashMapV8
2648 +     * from the given type to {@code Boolean.TRUE}.
2649 +     *
2650 +     * @param initialCapacity The implementation performs internal
2651 +     * sizing to accommodate this many elements.
2652 +     * @throws IllegalArgumentException if the initial capacity of
2653 +     * elements is negative
2654 +     * @return the new set
2655 +     */
2656 +    public static <K> KeySetView<K,Boolean> newKeySet(int initialCapacity) {
2657 +        return new KeySetView<K,Boolean>(new ConcurrentHashMapV8<K,Boolean>(initialCapacity),
2658 +                                      Boolean.TRUE);
2659 +    }
2660 +
2661 +    /**
2662       * {@inheritDoc}
2663       */
2664      public boolean isEmpty() {
# Line 2464 | Line 2677 | public class ConcurrentHashMapV8<K, V>
2677  
2678      /**
2679       * Returns the number of mappings. This method should be used
2680 <     * instead of {@link #size} because a ConcurrentHashMap may
2680 >     * instead of {@link #size} because a ConcurrentHashMapV8 may
2681       * contain more mappings than can be represented as an int. The
2682       * value returned is a snapshot; the actual count may differ if
2683       * there are ongoing concurrent insertions or removals.
# Line 2494 | Line 2707 | public class ConcurrentHashMapV8<K, V>
2707      }
2708  
2709      /**
2710 +     * Returns the value to which the specified key is mapped,
2711 +     * or the given defaultValue if this map contains no mapping for the key.
2712 +     *
2713 +     * @param key the key
2714 +     * @param defaultValue the value to return if this map contains
2715 +     * no mapping for the given key
2716 +     * @return the mapping for the key, if present; else the defaultValue
2717 +     * @throws NullPointerException if the specified key is null
2718 +     */
2719 +    @SuppressWarnings("unchecked") public V getValueOrDefault(Object key, V defaultValue) {
2720 +        if (key == null)
2721 +            throw new NullPointerException();
2722 +        V v = (V) internalGet(key);
2723 +        return v == null ? defaultValue : v;
2724 +    }
2725 +
2726 +    /**
2727       * Tests if the specified object is a key in this table.
2728       *
2729       * @param  key   possible key
# Line 2622 | Line 2852 | public class ConcurrentHashMapV8<K, V>
2852       * @param key key with which the specified value is to be associated
2853       * @param mappingFunction the function to compute a value
2854       * @return the current (existing or computed) value associated with
2855 <     *         the specified key, or null if the computed value is null.
2855 >     *         the specified key, or null if the computed value is null
2856       * @throws NullPointerException if the specified key or mappingFunction
2857       *         is null
2858       * @throws IllegalStateException if the computation detectably
# Line 2820 | Line 3050 | public class ConcurrentHashMapV8<K, V>
3050      /**
3051       * Returns a {@link Set} view of the keys contained in this map.
3052       * The set is backed by the map, so changes to the map are
3053 <     * reflected in the set, and vice-versa.  The set supports element
2824 <     * removal, which removes the corresponding mapping from this map,
2825 <     * via the {@code Iterator.remove}, {@code Set.remove},
2826 <     * {@code removeAll}, {@code retainAll}, and {@code clear}
2827 <     * operations.  It does not support the {@code add} or
2828 <     * {@code addAll} operations.
3053 >     * reflected in the set, and vice-versa.
3054       *
3055 <     * <p>The view's {@code iterator} is a "weakly consistent" iterator
2831 <     * that will never throw {@link ConcurrentModificationException},
2832 <     * and guarantees to traverse elements as they existed upon
2833 <     * construction of the iterator, and may (but is not guaranteed to)
2834 <     * reflect any modifications subsequent to construction.
3055 >     * @return the set view
3056       */
3057 <    public Set<K> keySet() {
3058 <        KeySet<K,V> ks = keySet;
3059 <        return (ks != null) ? ks : (keySet = new KeySet<K,V>(this));
3057 >    public KeySetView<K,V> keySet() {
3058 >        KeySetView<K,V> ks = keySet;
3059 >        return (ks != null) ? ks : (keySet = new KeySetView<K,V>(this, null));
3060 >    }
3061 >
3062 >    /**
3063 >     * Returns a {@link Set} view of the keys in this map, using the
3064 >     * given common mapped value for any additions (i.e., {@link
3065 >     * Collection#add} and {@link Collection#addAll}). This is of
3066 >     * course only appropriate if it is acceptable to use the same
3067 >     * value for all additions from this view.
3068 >     *
3069 >     * @param mappedValue the mapped value to use for any
3070 >     * additions.
3071 >     * @return the set view
3072 >     * @throws NullPointerException if the mappedValue is null
3073 >     */
3074 >    public KeySetView<K,V> keySet(V mappedValue) {
3075 >        if (mappedValue == null)
3076 >            throw new NullPointerException();
3077 >        return new KeySetView<K,V>(this, mappedValue);
3078      }
3079  
3080      /**
# Line 3017 | Line 3256 | public class ConcurrentHashMapV8<K, V>
3256              super(it);
3257          }
3258          public KeyIterator<K,V> split() {
3259 <            if (last != null || (next != null && nextVal == null))
3259 >            if (nextKey != null)
3260                  throw new IllegalStateException();
3261              return new KeyIterator<K,V>(this);
3262          }
# Line 3039 | Line 3278 | public class ConcurrentHashMapV8<K, V>
3278              super(it);
3279          }
3280          public ValueIterator<K,V> split() {
3281 <            if (last != null || (next != null && nextVal == null))
3281 >            if (nextKey != null)
3282                  throw new IllegalStateException();
3283              return new ValueIterator<K,V>(this);
3284          }
# Line 3062 | Line 3301 | public class ConcurrentHashMapV8<K, V>
3301              super(it);
3302          }
3303          public EntryIterator<K,V> split() {
3304 <            if (last != null || (next != null && nextVal == null))
3304 >            if (nextKey != null)
3305                  throw new IllegalStateException();
3306              return new EntryIterator<K,V>(this);
3307          }
# Line 3250 | Line 3489 | public class ConcurrentHashMapV8<K, V>
3489  
3490      }
3491  
3253    static final class KeySet<K,V> extends CHMView<K,V> implements Set<K> {
3254        KeySet(ConcurrentHashMapV8<K, V> map)  {
3255            super(map);
3256        }
3257        public final boolean contains(Object o) { return map.containsKey(o); }
3258        public final boolean remove(Object o)   { return map.remove(o) != null; }
3259        public final Iterator<K> iterator() {
3260            return new KeyIterator<K,V>(map);
3261        }
3262        public final boolean add(K e) {
3263            throw new UnsupportedOperationException();
3264        }
3265        public final boolean addAll(Collection<? extends K> c) {
3266            throw new UnsupportedOperationException();
3267        }
3268        public boolean equals(Object o) {
3269            Set<?> c;
3270            return ((o instanceof Set) &&
3271                    ((c = (Set<?>)o) == this ||
3272                     (containsAll(c) && c.containsAll(this))));
3273        }
3274    }
3275
3276
3492      static final class Values<K,V> extends CHMView<K,V>
3493          implements Collection<V> {
3494          Values(ConcurrentHashMapV8<K, V> map)   { super(map); }
# Line 3503 | Line 3718 | public class ConcurrentHashMapV8<K, V>
3718      // -------------------------------------------------------
3719  
3720      /**
3721 <     * Returns an extended {@link Parallel} view of this map using the
3507 <     * given executor for bulk parallel operations.
3721 >     * Performs the given action for each (key, value).
3722       *
3723 <     * @param executor the executor
3510 <     * @return a parallel view
3723 >     * @param action the action
3724       */
3725 <    public Parallel parallel(ForkJoinPool executor)  {
3726 <        return new Parallel(executor);
3725 >    public void forEach(BiAction<K,V> action) {
3726 >        ForkJoinTasks.forEach
3727 >            (this, action).invoke();
3728      }
3729  
3730      /**
3731 <     * An extended view of a ConcurrentHashMap supporting bulk
3732 <     * parallel operations. These operations are designed to be
3733 <     * safely, and often sensibly, applied even with maps that are
3734 <     * being concurrently updated by other threads; for example, when
3735 <     * computing a snapshot summary of the values in a shared
3736 <     * registry.  There are three kinds of operation, each with four
3737 <     * forms, accepting functions with Keys, Values, Entries, and
3524 <     * (Key, Value) arguments and/or return values. Because the
3525 <     * elements of a ConcurrentHashMap are not ordered in any
3526 <     * particular way, and may be processed in different orders in
3527 <     * different parallel executions, the correctness of supplied
3528 <     * functions should not depend on any ordering, or on any other
3529 <     * objects or values that may transiently change while computation
3530 <     * is in progress; and except for forEach actions, should ideally
3531 <     * be side-effect-free.
3532 <     *
3533 <     * <ul>
3534 <     * <li> forEach: Perform a given action on each element.
3535 <     * A variant form applies a given transformation on each element
3536 <     * before performing the action.</li>
3537 <     *
3538 <     * <li> search: Return the first available non-null result of
3539 <     * applying a given function on each element; skipping further
3540 <     * search when a result is found.</li>
3541 <     *
3542 <     * <li> reduce: Accumulate each element.  The supplied reduction
3543 <     * function cannot rely on ordering (more formally, it should be
3544 <     * both associative and commutative).  There are five variants:
3545 <     *
3546 <     * <ul>
3547 <     *
3548 <     * <li> Plain reductions. (There is not a form of this method for
3549 <     * (key, value) function arguments since there is no corresponding
3550 <     * return type.)</li>
3551 <     *
3552 <     * <li> Mapped reductions that accumulate the results of a given
3553 <     * function applied to each element.</li>
3554 <     *
3555 <     * <li> Reductions to scalar doubles, longs, and ints, using a
3556 <     * given basis value.</li>
3557 <     *
3558 <     * </li>
3559 <     * </ul>
3560 <     * </ul>
3561 <     *
3562 <     * <p>The concurrency properties of the bulk operations follow
3563 <     * from those of ConcurrentHashMap: Any non-null result returned
3564 <     * from {@code get(key)} and related access methods bears a
3565 <     * happens-before relation with the associated insertion or
3566 <     * update.  The result of any bulk operation reflects the
3567 <     * composition of these per-element relations (but is not
3568 <     * necessarily atomic with respect to the map as a whole unless it
3569 <     * is somehow known to be quiescent).  Conversely, because keys
3570 <     * and values in the map are never null, null serves as a reliable
3571 <     * atomic indicator of the current lack of any result.  To
3572 <     * maintain this property, null serves as an implicit basis for
3573 <     * all non-scalar reduction operations. For the double, long, and
3574 <     * int versions, the basis should be one that, when combined with
3575 <     * any other value, returns that other value (more formally, it
3576 <     * should be the identity element for the reduction). Most common
3577 <     * reductions have these properties; for example, computing a sum
3578 <     * with basis 0 or a minimum with basis MAX_VALUE.
3579 <     *
3580 <     * <p>Search and transformation functions provided as arguments
3581 <     * should similarly return null to indicate the lack of any result
3582 <     * (in which case it is not used). In the case of mapped
3583 <     * reductions, this also enables transformations to serve as
3584 <     * filters, returning null (or, in the case of primitive
3585 <     * specializations, the identity basis) if the element should not
3586 <     * be combined. You can create compound transformations and
3587 <     * filterings by composing them yourself under this "null means
3588 <     * there is nothing there now" rule before using them in search or
3589 <     * reduce operations.
3590 <     *
3591 <     * <p>Methods accepting and/or returning Entry arguments maintain
3592 <     * key-value associations. They may be useful for example when
3593 <     * finding the key for the greatest value. Note that "plain" Entry
3594 <     * arguments can be supplied using {@code new
3595 <     * AbstractMap.SimpleEntry(k,v)}.
3596 <     *
3597 <     * <p> Bulk operations may complete abruptly, throwing an
3598 <     * exception encountered in the application of a supplied
3599 <     * function. Bear in mind when handling such exceptions that other
3600 <     * concurrently executing functions could also have thrown
3601 <     * exceptions, or would have done so if the first exception had
3602 <     * not occurred.
3603 <     *
3604 <     * <p>Parallel speedups compared to sequential processing are
3605 <     * common but not guaranteed.  Operations involving brief
3606 <     * functions on small maps may execute more slowly than sequential
3607 <     * loops if the underlying work to parallelize the computation is
3608 <     * more expensive than the computation itself. Similarly,
3609 <     * parallelization may not lead to much actual parallelism if all
3610 <     * processors are busy performing unrelated tasks.
3611 <     *
3612 <     * <p> All arguments to all task methods must be non-null.
3613 <     *
3614 <     * <p><em>jsr166e note: During transition, this class
3615 <     * uses nested functional interfaces with different names but the
3616 <     * same forms as those expected for JDK8.<em>
3731 >     * Performs the given action for each non-null transformation
3732 >     * of each (key, value).
3733 >     *
3734 >     * @param transformer a function returning the transformation
3735 >     * for an element, or null of there is no transformation (in
3736 >     * which case the action is not applied).
3737 >     * @param action the action
3738       */
3739 <    public class Parallel {
3740 <        final ForkJoinPool fjp;
3739 >    public <U> void forEach(BiFun<? super K, ? super V, ? extends U> transformer,
3740 >                            Action<U> action) {
3741 >        ForkJoinTasks.forEach
3742 >            (this, transformer, action).invoke();
3743 >    }
3744  
3745 <        /**
3746 <         * Returns an extended view of this map using the given
3747 <         * executor for bulk parallel operations.
3748 <         *
3749 <         * @param executor the executor
3750 <         */
3751 <        public Parallel(ForkJoinPool executor)  {
3752 <            this.fjp = executor;
3753 <        }
3745 >    /**
3746 >     * Returns a non-null result from applying the given search
3747 >     * function on each (key, value), or null if none.  Upon
3748 >     * success, further element processing is suppressed and the
3749 >     * results of any other parallel invocations of the search
3750 >     * function are ignored.
3751 >     *
3752 >     * @param searchFunction a function returning a non-null
3753 >     * result on success, else null
3754 >     * @return a non-null result from applying the given search
3755 >     * function on each (key, value), or null if none
3756 >     */
3757 >    public <U> U search(BiFun<? super K, ? super V, ? extends U> searchFunction) {
3758 >        return ForkJoinTasks.search
3759 >            (this, searchFunction).invoke();
3760 >    }
3761  
3762 <        /**
3763 <         * Performs the given action for each (key, value).
3764 <         *
3765 <         * @param action the action
3766 <         */
3767 <        public void forEach(BiAction<K,V> action) {
3768 <            fjp.invoke(ForkJoinTasks.forEach
3769 <                       (ConcurrentHashMapV8.this, action));
3770 <        }
3762 >    /**
3763 >     * Returns the result of accumulating the given transformation
3764 >     * of all (key, value) pairs using the given reducer to
3765 >     * combine values, or null if none.
3766 >     *
3767 >     * @param transformer a function returning the transformation
3768 >     * for an element, or null of there is no transformation (in
3769 >     * which case it is not combined).
3770 >     * @param reducer a commutative associative combining function
3771 >     * @return the result of accumulating the given transformation
3772 >     * of all (key, value) pairs
3773 >     */
3774 >    public <U> U reduce(BiFun<? super K, ? super V, ? extends U> transformer,
3775 >                        BiFun<? super U, ? super U, ? extends U> reducer) {
3776 >        return ForkJoinTasks.reduce
3777 >            (this, transformer, reducer).invoke();
3778 >    }
3779  
3780 <        /**
3781 <         * Performs the given action for each non-null transformation
3782 <         * of each (key, value).
3783 <         *
3784 <         * @param transformer a function returning the transformation
3785 <         * for an element, or null of there is no transformation (in
3786 <         * which case the action is not applied).
3787 <         * @param action the action
3788 <         */
3789 <        public <U> void forEach(BiFun<? super K, ? super V, ? extends U> transformer,
3790 <                                Action<U> action) {
3791 <            fjp.invoke(ForkJoinTasks.forEach
3792 <                       (ConcurrentHashMapV8.this, transformer, action));
3793 <        }
3780 >    /**
3781 >     * Returns the result of accumulating the given transformation
3782 >     * of all (key, value) pairs using the given reducer to
3783 >     * combine values, and the given basis as an identity value.
3784 >     *
3785 >     * @param transformer a function returning the transformation
3786 >     * for an element
3787 >     * @param basis the identity (initial default value) for the reduction
3788 >     * @param reducer a commutative associative combining function
3789 >     * @return the result of accumulating the given transformation
3790 >     * of all (key, value) pairs
3791 >     */
3792 >    public double reduceToDouble(ObjectByObjectToDouble<? super K, ? super V> transformer,
3793 >                                 double basis,
3794 >                                 DoubleByDoubleToDouble reducer) {
3795 >        return ForkJoinTasks.reduceToDouble
3796 >            (this, transformer, basis, reducer).invoke();
3797 >    }
3798  
3799 <        /**
3800 <         * Returns a non-null result from applying the given search
3801 <         * function on each (key, value), or null if none.  Upon
3802 <         * success, further element processing is suppressed and the
3803 <         * results of any other parallel invocations of the search
3804 <         * function are ignored.
3805 <         *
3806 <         * @param searchFunction a function returning a non-null
3807 <         * result on success, else null
3808 <         * @return a non-null result from applying the given search
3809 <         * function on each (key, value), or null if none
3810 <         */
3811 <        public <U> U search(BiFun<? super K, ? super V, ? extends U> searchFunction) {
3812 <            return fjp.invoke(ForkJoinTasks.search
3813 <                              (ConcurrentHashMapV8.this, searchFunction));
3814 <        }
3799 >    /**
3800 >     * Returns the result of accumulating the given transformation
3801 >     * of all (key, value) pairs using the given reducer to
3802 >     * combine values, and the given basis as an identity value.
3803 >     *
3804 >     * @param transformer a function returning the transformation
3805 >     * for an element
3806 >     * @param basis the identity (initial default value) for the reduction
3807 >     * @param reducer a commutative associative combining function
3808 >     * @return the result of accumulating the given transformation
3809 >     * of all (key, value) pairs
3810 >     */
3811 >    public long reduceToLong(ObjectByObjectToLong<? super K, ? super V> transformer,
3812 >                             long basis,
3813 >                             LongByLongToLong reducer) {
3814 >        return ForkJoinTasks.reduceToLong
3815 >            (this, transformer, basis, reducer).invoke();
3816 >    }
3817  
3818 <        /**
3819 <         * Returns the result of accumulating the given transformation
3820 <         * of all (key, value) pairs using the given reducer to
3821 <         * combine values, or null if none.
3822 <         *
3823 <         * @param transformer a function returning the transformation
3824 <         * for an element, or null of there is no transformation (in
3825 <         * which case it is not combined).
3826 <         * @param reducer a commutative associative combining function
3827 <         * @return the result of accumulating the given transformation
3828 <         * of all (key, value) pairs
3829 <         */
3830 <        public <U> U reduce(BiFun<? super K, ? super V, ? extends U> transformer,
3818 >    /**
3819 >     * Returns the result of accumulating the given transformation
3820 >     * of all (key, value) pairs using the given reducer to
3821 >     * combine values, and the given basis as an identity value.
3822 >     *
3823 >     * @param transformer a function returning the transformation
3824 >     * for an element
3825 >     * @param basis the identity (initial default value) for the reduction
3826 >     * @param reducer a commutative associative combining function
3827 >     * @return the result of accumulating the given transformation
3828 >     * of all (key, value) pairs
3829 >     */
3830 >    public int reduceToInt(ObjectByObjectToInt<? super K, ? super V> transformer,
3831 >                           int basis,
3832 >                           IntByIntToInt reducer) {
3833 >        return ForkJoinTasks.reduceToInt
3834 >            (this, transformer, basis, reducer).invoke();
3835 >    }
3836 >
3837 >    /**
3838 >     * Performs the given action for each key.
3839 >     *
3840 >     * @param action the action
3841 >     */
3842 >    public void forEachKey(Action<K> action) {
3843 >        ForkJoinTasks.forEachKey
3844 >            (this, action).invoke();
3845 >    }
3846 >
3847 >    /**
3848 >     * Performs the given action for each non-null transformation
3849 >     * of each key.
3850 >     *
3851 >     * @param transformer a function returning the transformation
3852 >     * for an element, or null of there is no transformation (in
3853 >     * which case the action is not applied).
3854 >     * @param action the action
3855 >     */
3856 >    public <U> void forEachKey(Fun<? super K, ? extends U> transformer,
3857 >                               Action<U> action) {
3858 >        ForkJoinTasks.forEachKey
3859 >            (this, transformer, action).invoke();
3860 >    }
3861 >
3862 >    /**
3863 >     * Returns the result of accumulating all keys using the given
3864 >     * reducer to combine values, or null if none.
3865 >     *
3866 >     * @param reducer a commutative associative combining function
3867 >     * @return the result of accumulating all keys using the given
3868 >     * reducer to combine values, or null if none
3869 >     */
3870 >    public K reduceKeys(BiFun<? super K, ? super K, ? extends K> reducer) {
3871 >        return ForkJoinTasks.reduceKeys
3872 >            (this, reducer).invoke();
3873 >    }
3874 >
3875 >    /**
3876 >     * Returns the result of accumulating the given transformation
3877 >     * of all keys using the given reducer to combine values, or
3878 >     * null if none.
3879 >     *
3880 >     * @param transformer a function returning the transformation
3881 >     * for an element, or null of there is no transformation (in
3882 >     * which case it is not combined).
3883 >     * @param reducer a commutative associative combining function
3884 >     * @return the result of accumulating the given transformation
3885 >     * of all keys
3886 >     */
3887 >    public <U> U reduceKeys(Fun<? super K, ? extends U> transformer,
3888                              BiFun<? super U, ? super U, ? extends U> reducer) {
3889 <            return fjp.invoke(ForkJoinTasks.reduce
3890 <                              (ConcurrentHashMapV8.this, transformer, reducer));
3891 <        }
3889 >        return ForkJoinTasks.reduceKeys
3890 >            (this, transformer, reducer).invoke();
3891 >    }
3892  
3893 <        /**
3894 <         * Returns the result of accumulating the given transformation
3895 <         * of all (key, value) pairs using the given reducer to
3896 <         * combine values, and the given basis as an identity value.
3897 <         *
3898 <         * @param transformer a function returning the transformation
3899 <         * for an element
3900 <         * @param basis the identity (initial default value) for the reduction
3901 <         * @param reducer a commutative associative combining function
3902 <         * @return the result of accumulating the given transformation
3903 <         * of all (key, value) pairs
3904 <         */
3905 <        public double reduceToDouble(ObjectByObjectToDouble<? super K, ? super V> transformer,
3893 >    /**
3894 >     * Returns the result of accumulating the given transformation
3895 >     * of all keys using the given reducer to combine values, and
3896 >     * the given basis as an identity value.
3897 >     *
3898 >     * @param transformer a function returning the transformation
3899 >     * for an element
3900 >     * @param basis the identity (initial default value) for the reduction
3901 >     * @param reducer a commutative associative combining function
3902 >     * @return  the result of accumulating the given transformation
3903 >     * of all keys
3904 >     */
3905 >    public double reduceKeysToDouble(ObjectToDouble<? super K> transformer,
3906                                       double basis,
3907                                       DoubleByDoubleToDouble reducer) {
3908 <            return fjp.invoke(ForkJoinTasks.reduceToDouble
3909 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3910 <        }
3908 >        return ForkJoinTasks.reduceKeysToDouble
3909 >            (this, transformer, basis, reducer).invoke();
3910 >    }
3911  
3912 <        /**
3913 <         * Returns the result of accumulating the given transformation
3914 <         * of all (key, value) pairs using the given reducer to
3915 <         * combine values, and the given basis as an identity value.
3916 <         *
3917 <         * @param transformer a function returning the transformation
3918 <         * for an element
3919 <         * @param basis the identity (initial default value) for the reduction
3920 <         * @param reducer a commutative associative combining function
3921 <         * @return the result of accumulating the given transformation
3922 <         * of all (key, value) pairs
3923 <         */
3924 <        public long reduceToLong(ObjectByObjectToLong<? super K, ? super V> transformer,
3912 >    /**
3913 >     * Returns the result of accumulating the given transformation
3914 >     * of all keys using the given reducer to combine values, and
3915 >     * the given basis as an identity value.
3916 >     *
3917 >     * @param transformer a function returning the transformation
3918 >     * for an element
3919 >     * @param basis the identity (initial default value) for the reduction
3920 >     * @param reducer a commutative associative combining function
3921 >     * @return the result of accumulating the given transformation
3922 >     * of all keys
3923 >     */
3924 >    public long reduceKeysToLong(ObjectToLong<? super K> transformer,
3925                                   long basis,
3926                                   LongByLongToLong reducer) {
3927 <            return fjp.invoke(ForkJoinTasks.reduceToLong
3928 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3929 <        }
3927 >        return ForkJoinTasks.reduceKeysToLong
3928 >            (this, transformer, basis, reducer).invoke();
3929 >    }
3930  
3931 <        /**
3932 <         * Returns the result of accumulating the given transformation
3933 <         * of all (key, value) pairs using the given reducer to
3934 <         * combine values, and the given basis as an identity value.
3935 <         *
3936 <         * @param transformer a function returning the transformation
3937 <         * for an element
3938 <         * @param basis the identity (initial default value) for the reduction
3939 <         * @param reducer a commutative associative combining function
3940 <         * @return the result of accumulating the given transformation
3941 <         * of all (key, value) pairs
3942 <         */
3943 <        public int reduceToInt(ObjectByObjectToInt<? super K, ? super V> transformer,
3931 >    /**
3932 >     * Returns the result of accumulating the given transformation
3933 >     * of all keys using the given reducer to combine values, and
3934 >     * the given basis as an identity value.
3935 >     *
3936 >     * @param transformer a function returning the transformation
3937 >     * for an element
3938 >     * @param basis the identity (initial default value) for the reduction
3939 >     * @param reducer a commutative associative combining function
3940 >     * @return the result of accumulating the given transformation
3941 >     * of all keys
3942 >     */
3943 >    public int reduceKeysToInt(ObjectToInt<? super K> transformer,
3944                                 int basis,
3945                                 IntByIntToInt reducer) {
3946 <            return fjp.invoke(ForkJoinTasks.reduceToInt
3947 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3948 <        }
3747 <
3748 <        /**
3749 <         * Performs the given action for each key.
3750 <         *
3751 <         * @param action the action
3752 <         */
3753 <        public void forEachKey(Action<K> action) {
3754 <            fjp.invoke(ForkJoinTasks.forEachKey
3755 <                       (ConcurrentHashMapV8.this, action));
3756 <        }
3757 <
3758 <        /**
3759 <         * Performs the given action for each non-null transformation
3760 <         * of each key.
3761 <         *
3762 <         * @param transformer a function returning the transformation
3763 <         * for an element, or null of there is no transformation (in
3764 <         * which case the action is not applied).
3765 <         * @param action the action
3766 <         */
3767 <        public <U> void forEachKey(Fun<? super K, ? extends U> transformer,
3768 <                                   Action<U> action) {
3769 <            fjp.invoke(ForkJoinTasks.forEachKey
3770 <                       (ConcurrentHashMapV8.this, transformer, action));
3771 <        }
3772 <
3773 <        /**
3774 <         * Returns a non-null result from applying the given search
3775 <         * function on each key, or null if none. Upon success,
3776 <         * further element processing is suppressed and the results of
3777 <         * any other parallel invocations of the search function are
3778 <         * ignored.
3779 <         *
3780 <         * @param searchFunction a function returning a non-null
3781 <         * result on success, else null
3782 <         * @return a non-null result from applying the given search
3783 <         * function on each key, or null if none
3784 <         */
3785 <        public <U> U searchKeys(Fun<? super K, ? extends U> searchFunction) {
3786 <            return fjp.invoke(ForkJoinTasks.searchKeys
3787 <                              (ConcurrentHashMapV8.this, searchFunction));
3788 <        }
3789 <
3790 <        /**
3791 <         * Returns the result of accumulating all keys using the given
3792 <         * reducer to combine values, or null if none.
3793 <         *
3794 <         * @param reducer a commutative associative combining function
3795 <         * @return the result of accumulating all keys using the given
3796 <         * reducer to combine values, or null if none
3797 <         */
3798 <        public K reduceKeys(BiFun<? super K, ? super K, ? extends K> reducer) {
3799 <            return fjp.invoke(ForkJoinTasks.reduceKeys
3800 <                              (ConcurrentHashMapV8.this, reducer));
3801 <        }
3802 <
3803 <        /**
3804 <         * Returns the result of accumulating the given transformation
3805 <         * of all keys using the given reducer to combine values, or
3806 <         * null if none.
3807 <         *
3808 <         * @param transformer a function returning the transformation
3809 <         * for an element, or null of there is no transformation (in
3810 <         * which case it is not combined).
3811 <         * @param reducer a commutative associative combining function
3812 <         * @return the result of accumulating the given transformation
3813 <         * of all keys
3814 <         */
3815 <        public <U> U reduceKeys(Fun<? super K, ? extends U> transformer,
3816 <                                BiFun<? super U, ? super U, ? extends U> reducer) {
3817 <            return fjp.invoke(ForkJoinTasks.reduceKeys
3818 <                              (ConcurrentHashMapV8.this, transformer, reducer));
3819 <        }
3820 <
3821 <        /**
3822 <         * Returns the result of accumulating the given transformation
3823 <         * of all keys using the given reducer to combine values, and
3824 <         * the given basis as an identity value.
3825 <         *
3826 <         * @param transformer a function returning the transformation
3827 <         * for an element
3828 <         * @param basis the identity (initial default value) for the reduction
3829 <         * @param reducer a commutative associative combining function
3830 <         * @return  the result of accumulating the given transformation
3831 <         * of all keys
3832 <         */
3833 <        public double reduceKeysToDouble(ObjectToDouble<? super K> transformer,
3834 <                                         double basis,
3835 <                                         DoubleByDoubleToDouble reducer) {
3836 <            return fjp.invoke(ForkJoinTasks.reduceKeysToDouble
3837 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3838 <        }
3839 <
3840 <        /**
3841 <         * Returns the result of accumulating the given transformation
3842 <         * of all keys using the given reducer to combine values, and
3843 <         * the given basis as an identity value.
3844 <         *
3845 <         * @param transformer a function returning the transformation
3846 <         * for an element
3847 <         * @param basis the identity (initial default value) for the reduction
3848 <         * @param reducer a commutative associative combining function
3849 <         * @return the result of accumulating the given transformation
3850 <         * of all keys
3851 <         */
3852 <        public long reduceKeysToLong(ObjectToLong<? super K> transformer,
3853 <                                     long basis,
3854 <                                     LongByLongToLong reducer) {
3855 <            return fjp.invoke(ForkJoinTasks.reduceKeysToLong
3856 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3857 <        }
3858 <
3859 <        /**
3860 <         * Returns the result of accumulating the given transformation
3861 <         * of all keys using the given reducer to combine values, and
3862 <         * the given basis as an identity value.
3863 <         *
3864 <         * @param transformer a function returning the transformation
3865 <         * for an element
3866 <         * @param basis the identity (initial default value) for the reduction
3867 <         * @param reducer a commutative associative combining function
3868 <         * @return the result of accumulating the given transformation
3869 <         * of all keys
3870 <         */
3871 <        public int reduceKeysToInt(ObjectToInt<? super K> transformer,
3872 <                                   int basis,
3873 <                                   IntByIntToInt reducer) {
3874 <            return fjp.invoke(ForkJoinTasks.reduceKeysToInt
3875 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3876 <        }
3946 >        return ForkJoinTasks.reduceKeysToInt
3947 >            (this, transformer, basis, reducer).invoke();
3948 >    }
3949  
3950 <        /**
3951 <         * Performs the given action for each value.
3952 <         *
3953 <         * @param action the action
3954 <         */
3955 <        public void forEachValue(Action<V> action) {
3956 <            fjp.invoke(ForkJoinTasks.forEachValue
3957 <                       (ConcurrentHashMapV8.this, action));
3958 <        }
3950 >    /**
3951 >     * Performs the given action for each value.
3952 >     *
3953 >     * @param action the action
3954 >     */
3955 >    public void forEachValue(Action<V> action) {
3956 >        ForkJoinTasks.forEachValue
3957 >            (this, action).invoke();
3958 >    }
3959  
3960 <        /**
3961 <         * Performs the given action for each non-null transformation
3962 <         * of each value.
3963 <         *
3964 <         * @param transformer a function returning the transformation
3965 <         * for an element, or null of there is no transformation (in
3966 <         * which case the action is not applied).
3967 <         */
3968 <        public <U> void forEachValue(Fun<? super V, ? extends U> transformer,
3969 <                                     Action<U> action) {
3970 <            fjp.invoke(ForkJoinTasks.forEachValue
3971 <                       (ConcurrentHashMapV8.this, transformer, action));
3972 <        }
3960 >    /**
3961 >     * Performs the given action for each non-null transformation
3962 >     * of each value.
3963 >     *
3964 >     * @param transformer a function returning the transformation
3965 >     * for an element, or null of there is no transformation (in
3966 >     * which case the action is not applied).
3967 >     */
3968 >    public <U> void forEachValue(Fun<? super V, ? extends U> transformer,
3969 >                                 Action<U> action) {
3970 >        ForkJoinTasks.forEachValue
3971 >            (this, transformer, action).invoke();
3972 >    }
3973  
3974 <        /**
3975 <         * Returns a non-null result from applying the given search
3976 <         * function on each value, or null if none.  Upon success,
3977 <         * further element processing is suppressed and the results of
3978 <         * any other parallel invocations of the search function are
3979 <         * ignored.
3980 <         *
3981 <         * @param searchFunction a function returning a non-null
3982 <         * result on success, else null
3983 <         * @return a non-null result from applying the given search
3984 <         * function on each value, or null if none
3985 <         *
3986 <         */
3987 <        public <U> U searchValues(Fun<? super V, ? extends U> searchFunction) {
3988 <            return fjp.invoke(ForkJoinTasks.searchValues
3989 <                              (ConcurrentHashMapV8.this, searchFunction));
3990 <        }
3974 >    /**
3975 >     * Returns a non-null result from applying the given search
3976 >     * function on each value, or null if none.  Upon success,
3977 >     * further element processing is suppressed and the results of
3978 >     * any other parallel invocations of the search function are
3979 >     * ignored.
3980 >     *
3981 >     * @param searchFunction a function returning a non-null
3982 >     * result on success, else null
3983 >     * @return a non-null result from applying the given search
3984 >     * function on each value, or null if none
3985 >     *
3986 >     */
3987 >    public <U> U searchValues(Fun<? super V, ? extends U> searchFunction) {
3988 >        return ForkJoinTasks.searchValues
3989 >            (this, searchFunction).invoke();
3990 >    }
3991  
3992 <        /**
3993 <         * Returns the result of accumulating all values using the
3994 <         * given reducer to combine values, or null if none.
3995 <         *
3996 <         * @param reducer a commutative associative combining function
3997 <         * @return  the result of accumulating all values
3998 <         */
3999 <        public V reduceValues(BiFun<? super V, ? super V, ? extends V> reducer) {
4000 <            return fjp.invoke(ForkJoinTasks.reduceValues
4001 <                              (ConcurrentHashMapV8.this, reducer));
4002 <        }
3992 >    /**
3993 >     * Returns the result of accumulating all values using the
3994 >     * given reducer to combine values, or null if none.
3995 >     *
3996 >     * @param reducer a commutative associative combining function
3997 >     * @return  the result of accumulating all values
3998 >     */
3999 >    public V reduceValues(BiFun<? super V, ? super V, ? extends V> reducer) {
4000 >        return ForkJoinTasks.reduceValues
4001 >            (this, reducer).invoke();
4002 >    }
4003  
4004 <        /**
4005 <         * Returns the result of accumulating the given transformation
4006 <         * of all values using the given reducer to combine values, or
4007 <         * null if none.
4008 <         *
4009 <         * @param transformer a function returning the transformation
4010 <         * for an element, or null of there is no transformation (in
4011 <         * which case it is not combined).
4012 <         * @param reducer a commutative associative combining function
4013 <         * @return the result of accumulating the given transformation
4014 <         * of all values
4015 <         */
4016 <        public <U> U reduceValues(Fun<? super V, ? extends U> transformer,
4017 <                                  BiFun<? super U, ? super U, ? extends U> reducer) {
4018 <            return fjp.invoke(ForkJoinTasks.reduceValues
4019 <                              (ConcurrentHashMapV8.this, transformer, reducer));
4020 <        }
4004 >    /**
4005 >     * Returns the result of accumulating the given transformation
4006 >     * of all values using the given reducer to combine values, or
4007 >     * null if none.
4008 >     *
4009 >     * @param transformer a function returning the transformation
4010 >     * for an element, or null of there is no transformation (in
4011 >     * which case it is not combined).
4012 >     * @param reducer a commutative associative combining function
4013 >     * @return the result of accumulating the given transformation
4014 >     * of all values
4015 >     */
4016 >    public <U> U reduceValues(Fun<? super V, ? extends U> transformer,
4017 >                              BiFun<? super U, ? super U, ? extends U> reducer) {
4018 >        return ForkJoinTasks.reduceValues
4019 >            (this, transformer, reducer).invoke();
4020 >    }
4021  
4022 <        /**
4023 <         * Returns the result of accumulating the given transformation
4024 <         * of all values using the given reducer to combine values,
4025 <         * and the given basis as an identity value.
4026 <         *
4027 <         * @param transformer a function returning the transformation
4028 <         * for an element
4029 <         * @param basis the identity (initial default value) for the reduction
4030 <         * @param reducer a commutative associative combining function
4031 <         * @return the result of accumulating the given transformation
4032 <         * of all values
4033 <         */
4034 <        public double reduceValuesToDouble(ObjectToDouble<? super V> transformer,
4035 <                                           double basis,
4036 <                                           DoubleByDoubleToDouble reducer) {
4037 <            return fjp.invoke(ForkJoinTasks.reduceValuesToDouble
4038 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
4039 <        }
4022 >    /**
4023 >     * Returns the result of accumulating the given transformation
4024 >     * of all values using the given reducer to combine values,
4025 >     * and the given basis as an identity value.
4026 >     *
4027 >     * @param transformer a function returning the transformation
4028 >     * for an element
4029 >     * @param basis the identity (initial default value) for the reduction
4030 >     * @param reducer a commutative associative combining function
4031 >     * @return the result of accumulating the given transformation
4032 >     * of all values
4033 >     */
4034 >    public double reduceValuesToDouble(ObjectToDouble<? super V> transformer,
4035 >                                       double basis,
4036 >                                       DoubleByDoubleToDouble reducer) {
4037 >        return ForkJoinTasks.reduceValuesToDouble
4038 >            (this, transformer, basis, reducer).invoke();
4039 >    }
4040  
4041 <        /**
4042 <         * Returns the result of accumulating the given transformation
4043 <         * of all values using the given reducer to combine values,
4044 <         * and the given basis as an identity value.
4045 <         *
4046 <         * @param transformer a function returning the transformation
4047 <         * for an element
4048 <         * @param basis the identity (initial default value) for the reduction
4049 <         * @param reducer a commutative associative combining function
4050 <         * @return the result of accumulating the given transformation
4051 <         * of all values
4052 <         */
4053 <        public long reduceValuesToLong(ObjectToLong<? super V> transformer,
4054 <                                       long basis,
4055 <                                       LongByLongToLong reducer) {
4056 <            return fjp.invoke(ForkJoinTasks.reduceValuesToLong
4057 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
4058 <        }
4041 >    /**
4042 >     * Returns the result of accumulating the given transformation
4043 >     * of all values using the given reducer to combine values,
4044 >     * and the given basis as an identity value.
4045 >     *
4046 >     * @param transformer a function returning the transformation
4047 >     * for an element
4048 >     * @param basis the identity (initial default value) for the reduction
4049 >     * @param reducer a commutative associative combining function
4050 >     * @return the result of accumulating the given transformation
4051 >     * of all values
4052 >     */
4053 >    public long reduceValuesToLong(ObjectToLong<? super V> transformer,
4054 >                                   long basis,
4055 >                                   LongByLongToLong reducer) {
4056 >        return ForkJoinTasks.reduceValuesToLong
4057 >            (this, transformer, basis, reducer).invoke();
4058 >    }
4059  
4060 <        /**
4061 <         * Returns the result of accumulating the given transformation
4062 <         * of all values using the given reducer to combine values,
4063 <         * and the given basis as an identity value.
4064 <         *
4065 <         * @param transformer a function returning the transformation
4066 <         * for an element
4067 <         * @param basis the identity (initial default value) for the reduction
4068 <         * @param reducer a commutative associative combining function
4069 <         * @return the result of accumulating the given transformation
4070 <         * of all values
4071 <         */
4072 <        public int reduceValuesToInt(ObjectToInt<? super V> transformer,
4073 <                                     int basis,
4074 <                                     IntByIntToInt reducer) {
4075 <            return fjp.invoke(ForkJoinTasks.reduceValuesToInt
4076 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
4077 <        }
4060 >    /**
4061 >     * Returns the result of accumulating the given transformation
4062 >     * of all values using the given reducer to combine values,
4063 >     * and the given basis as an identity value.
4064 >     *
4065 >     * @param transformer a function returning the transformation
4066 >     * for an element
4067 >     * @param basis the identity (initial default value) for the reduction
4068 >     * @param reducer a commutative associative combining function
4069 >     * @return the result of accumulating the given transformation
4070 >     * of all values
4071 >     */
4072 >    public int reduceValuesToInt(ObjectToInt<? super V> transformer,
4073 >                                 int basis,
4074 >                                 IntByIntToInt reducer) {
4075 >        return ForkJoinTasks.reduceValuesToInt
4076 >            (this, transformer, basis, reducer).invoke();
4077 >    }
4078  
4079 <        /**
4080 <         * Performs the given action for each entry.
4081 <         *
4082 <         * @param action the action
4083 <         */
4084 <        public void forEachEntry(Action<Map.Entry<K,V>> action) {
4085 <            fjp.invoke(ForkJoinTasks.forEachEntry
4086 <                       (ConcurrentHashMapV8.this, action));
4087 <        }
4079 >    /**
4080 >     * Performs the given action for each entry.
4081 >     *
4082 >     * @param action the action
4083 >     */
4084 >    public void forEachEntry(Action<Map.Entry<K,V>> action) {
4085 >        ForkJoinTasks.forEachEntry
4086 >            (this, action).invoke();
4087 >    }
4088  
4089 <        /**
4090 <         * Performs the given action for each non-null transformation
4091 <         * of each entry.
4092 <         *
4093 <         * @param transformer a function returning the transformation
4094 <         * for an element, or null of there is no transformation (in
4095 <         * which case the action is not applied).
4096 <         * @param action the action
4097 <         */
4098 <        public <U> void forEachEntry(Fun<Map.Entry<K,V>, ? extends U> transformer,
4099 <                                     Action<U> action) {
4100 <            fjp.invoke(ForkJoinTasks.forEachEntry
4101 <                       (ConcurrentHashMapV8.this, transformer, action));
4102 <        }
4089 >    /**
4090 >     * Performs the given action for each non-null transformation
4091 >     * of each entry.
4092 >     *
4093 >     * @param transformer a function returning the transformation
4094 >     * for an element, or null of there is no transformation (in
4095 >     * which case the action is not applied).
4096 >     * @param action the action
4097 >     */
4098 >    public <U> void forEachEntry(Fun<Map.Entry<K,V>, ? extends U> transformer,
4099 >                                 Action<U> action) {
4100 >        ForkJoinTasks.forEachEntry
4101 >            (this, transformer, action).invoke();
4102 >    }
4103  
4104 <        /**
4105 <         * Returns a non-null result from applying the given search
4106 <         * function on each entry, or null if none.  Upon success,
4107 <         * further element processing is suppressed and the results of
4108 <         * any other parallel invocations of the search function are
4109 <         * ignored.
4110 <         *
4111 <         * @param searchFunction a function returning a non-null
4112 <         * result on success, else null
4113 <         * @return a non-null result from applying the given search
4114 <         * function on each entry, or null if none
4115 <         */
4116 <        public <U> U searchEntries(Fun<Map.Entry<K,V>, ? extends U> searchFunction) {
4117 <            return fjp.invoke(ForkJoinTasks.searchEntries
4118 <                              (ConcurrentHashMapV8.this, searchFunction));
4119 <        }
4104 >    /**
4105 >     * Returns a non-null result from applying the given search
4106 >     * function on each entry, or null if none.  Upon success,
4107 >     * further element processing is suppressed and the results of
4108 >     * any other parallel invocations of the search function are
4109 >     * ignored.
4110 >     *
4111 >     * @param searchFunction a function returning a non-null
4112 >     * result on success, else null
4113 >     * @return a non-null result from applying the given search
4114 >     * function on each entry, or null if none
4115 >     */
4116 >    public <U> U searchEntries(Fun<Map.Entry<K,V>, ? extends U> searchFunction) {
4117 >        return ForkJoinTasks.searchEntries
4118 >            (this, searchFunction).invoke();
4119 >    }
4120  
4121 <        /**
4122 <         * Returns the result of accumulating all entries using the
4123 <         * given reducer to combine values, or null if none.
4124 <         *
4125 <         * @param reducer a commutative associative combining function
4126 <         * @return the result of accumulating all entries
4127 <         */
4128 <        public Map.Entry<K,V> reduceEntries(BiFun<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) {
4129 <            return fjp.invoke(ForkJoinTasks.reduceEntries
4130 <                              (ConcurrentHashMapV8.this, reducer));
4131 <        }
4121 >    /**
4122 >     * Returns the result of accumulating all entries using the
4123 >     * given reducer to combine values, or null if none.
4124 >     *
4125 >     * @param reducer a commutative associative combining function
4126 >     * @return the result of accumulating all entries
4127 >     */
4128 >    public Map.Entry<K,V> reduceEntries(BiFun<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) {
4129 >        return ForkJoinTasks.reduceEntries
4130 >            (this, reducer).invoke();
4131 >    }
4132  
4133 <        /**
4134 <         * Returns the result of accumulating the given transformation
4135 <         * of all entries using the given reducer to combine values,
4136 <         * or null if none.
4137 <         *
4138 <         * @param transformer a function returning the transformation
4139 <         * for an element, or null of there is no transformation (in
4140 <         * which case it is not combined).
4141 <         * @param reducer a commutative associative combining function
4142 <         * @return the result of accumulating the given transformation
4143 <         * of all entries
4144 <         */
4145 <        public <U> U reduceEntries(Fun<Map.Entry<K,V>, ? extends U> transformer,
4146 <                                   BiFun<? super U, ? super U, ? extends U> reducer) {
4147 <            return fjp.invoke(ForkJoinTasks.reduceEntries
4148 <                              (ConcurrentHashMapV8.this, transformer, reducer));
4149 <        }
4133 >    /**
4134 >     * Returns the result of accumulating the given transformation
4135 >     * of all entries using the given reducer to combine values,
4136 >     * or null if none.
4137 >     *
4138 >     * @param transformer a function returning the transformation
4139 >     * for an element, or null of there is no transformation (in
4140 >     * which case it is not combined).
4141 >     * @param reducer a commutative associative combining function
4142 >     * @return the result of accumulating the given transformation
4143 >     * of all entries
4144 >     */
4145 >    public <U> U reduceEntries(Fun<Map.Entry<K,V>, ? extends U> transformer,
4146 >                               BiFun<? super U, ? super U, ? extends U> reducer) {
4147 >        return ForkJoinTasks.reduceEntries
4148 >            (this, transformer, reducer).invoke();
4149 >    }
4150  
4151 <        /**
4152 <         * Returns the result of accumulating the given transformation
4153 <         * of all entries using the given reducer to combine values,
4154 <         * and the given basis as an identity value.
4155 <         *
4156 <         * @param transformer a function returning the transformation
4157 <         * for an element
4158 <         * @param basis the identity (initial default value) for the reduction
4159 <         * @param reducer a commutative associative combining function
4160 <         * @return the result of accumulating the given transformation
4161 <         * of all entries
4162 <         */
4163 <        public double reduceEntriesToDouble(ObjectToDouble<Map.Entry<K,V>> transformer,
4164 <                                            double basis,
4165 <                                            DoubleByDoubleToDouble reducer) {
4166 <            return fjp.invoke(ForkJoinTasks.reduceEntriesToDouble
4167 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
4168 <        }
4151 >    /**
4152 >     * Returns the result of accumulating the given transformation
4153 >     * of all entries using the given reducer to combine values,
4154 >     * and the given basis as an identity value.
4155 >     *
4156 >     * @param transformer a function returning the transformation
4157 >     * for an element
4158 >     * @param basis the identity (initial default value) for the reduction
4159 >     * @param reducer a commutative associative combining function
4160 >     * @return the result of accumulating the given transformation
4161 >     * of all entries
4162 >     */
4163 >    public double reduceEntriesToDouble(ObjectToDouble<Map.Entry<K,V>> transformer,
4164 >                                        double basis,
4165 >                                        DoubleByDoubleToDouble reducer) {
4166 >        return ForkJoinTasks.reduceEntriesToDouble
4167 >            (this, transformer, basis, reducer).invoke();
4168 >    }
4169  
4170 <        /**
4171 <         * Returns the result of accumulating the given transformation
4172 <         * of all entries using the given reducer to combine values,
4173 <         * and the given basis as an identity value.
4174 <         *
4175 <         * @param transformer a function returning the transformation
4176 <         * for an element
4177 <         * @param basis the identity (initial default value) for the reduction
4178 <         * @param reducer a commutative associative combining function
4179 <         * @return  the result of accumulating the given transformation
4180 <         * of all entries
4181 <         */
4182 <        public long reduceEntriesToLong(ObjectToLong<Map.Entry<K,V>> transformer,
4183 <                                        long basis,
4184 <                                        LongByLongToLong reducer) {
4185 <            return fjp.invoke(ForkJoinTasks.reduceEntriesToLong
4186 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
4187 <        }
4170 >    /**
4171 >     * Returns the result of accumulating the given transformation
4172 >     * of all entries using the given reducer to combine values,
4173 >     * and the given basis as an identity value.
4174 >     *
4175 >     * @param transformer a function returning the transformation
4176 >     * for an element
4177 >     * @param basis the identity (initial default value) for the reduction
4178 >     * @param reducer a commutative associative combining function
4179 >     * @return  the result of accumulating the given transformation
4180 >     * of all entries
4181 >     */
4182 >    public long reduceEntriesToLong(ObjectToLong<Map.Entry<K,V>> transformer,
4183 >                                    long basis,
4184 >                                    LongByLongToLong reducer) {
4185 >        return ForkJoinTasks.reduceEntriesToLong
4186 >            (this, transformer, basis, reducer).invoke();
4187 >    }
4188  
4189 <        /**
4190 <         * Returns the result of accumulating the given transformation
4191 <         * of all entries using the given reducer to combine values,
4192 <         * and the given basis as an identity value.
4193 <         *
4194 <         * @param transformer a function returning the transformation
4195 <         * for an element
4196 <         * @param basis the identity (initial default value) for the reduction
4197 <         * @param reducer a commutative associative combining function
4198 <         * @return the result of accumulating the given transformation
4199 <         * of all entries
4200 <         */
4201 <        public int reduceEntriesToInt(ObjectToInt<Map.Entry<K,V>> transformer,
4202 <                                      int basis,
4203 <                                      IntByIntToInt reducer) {
4204 <            return fjp.invoke(ForkJoinTasks.reduceEntriesToInt
4205 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
4134 <        }
4189 >    /**
4190 >     * Returns the result of accumulating the given transformation
4191 >     * of all entries using the given reducer to combine values,
4192 >     * and the given basis as an identity value.
4193 >     *
4194 >     * @param transformer a function returning the transformation
4195 >     * for an element
4196 >     * @param basis the identity (initial default value) for the reduction
4197 >     * @param reducer a commutative associative combining function
4198 >     * @return the result of accumulating the given transformation
4199 >     * of all entries
4200 >     */
4201 >    public int reduceEntriesToInt(ObjectToInt<Map.Entry<K,V>> transformer,
4202 >                                  int basis,
4203 >                                  IntByIntToInt reducer) {
4204 >        return ForkJoinTasks.reduceEntriesToInt
4205 >            (this, transformer, basis, reducer).invoke();
4206      }
4207  
4208      // ---------------------------------------------------------------------
4209  
4210      /**
4211       * Predefined tasks for performing bulk parallel operations on
4212 <     * ConcurrentHashMaps. These tasks follow the forms and rules used
4213 <     * in class {@link Parallel}. Each method has the same name, but
4214 <     * returns a task rather than invoking it. These methods may be
4215 <     * useful in custom applications such as submitting a task without
4216 <     * waiting for completion, or combining with other tasks.
4212 >     * ConcurrentHashMapV8s. These tasks follow the forms and rules used
4213 >     * for bulk operations. Each method has the same name, but returns
4214 >     * a task rather than invoking it. These methods may be useful in
4215 >     * custom applications such as submitting a task without waiting
4216 >     * for completion, using a custom pool, or combining with other
4217 >     * tasks.
4218       */
4219      public static class ForkJoinTasks {
4220          private ForkJoinTasks() {}
# Line 4159 | Line 4231 | public class ConcurrentHashMapV8<K, V>
4231              (ConcurrentHashMapV8<K,V> map,
4232               BiAction<K,V> action) {
4233              if (action == null) throw new NullPointerException();
4234 <            return new ForEachMappingTask<K,V>(map, action);
4234 >            return new ForEachMappingTask<K,V>(map, null, -1, null, action);
4235          }
4236  
4237          /**
# Line 4168 | Line 4240 | public class ConcurrentHashMapV8<K, V>
4240           *
4241           * @param map the map
4242           * @param transformer a function returning the transformation
4243 <         * for an element, or null of there is no transformation (in
4244 <         * which case the action is not applied).
4243 >         * for an element, or null if there is no transformation (in
4244 >         * which case the action is not applied)
4245           * @param action the action
4246           * @return the task
4247           */
# Line 4180 | Line 4252 | public class ConcurrentHashMapV8<K, V>
4252              if (transformer == null || action == null)
4253                  throw new NullPointerException();
4254              return new ForEachTransformedMappingTask<K,V,U>
4255 <                (map, transformer, action);
4255 >                (map, null, -1, null, transformer, action);
4256          }
4257  
4258          /**
# Line 4200 | Line 4272 | public class ConcurrentHashMapV8<K, V>
4272               BiFun<? super K, ? super V, ? extends U> searchFunction) {
4273              if (searchFunction == null) throw new NullPointerException();
4274              return new SearchMappingsTask<K,V,U>
4275 <                (map, searchFunction,
4275 >                (map, null, -1, null, searchFunction,
4276                   new AtomicReference<U>());
4277          }
4278  
# Line 4211 | Line 4283 | public class ConcurrentHashMapV8<K, V>
4283           *
4284           * @param map the map
4285           * @param transformer a function returning the transformation
4286 <         * for an element, or null of there is no transformation (in
4286 >         * for an element, or null if there is no transformation (in
4287           * which case it is not combined).
4288           * @param reducer a commutative associative combining function
4289           * @return the task
# Line 4223 | Line 4295 | public class ConcurrentHashMapV8<K, V>
4295              if (transformer == null || reducer == null)
4296                  throw new NullPointerException();
4297              return new MapReduceMappingsTask<K,V,U>
4298 <                (map, transformer, reducer);
4298 >                (map, null, -1, null, transformer, reducer);
4299          }
4300  
4301          /**
# Line 4247 | Line 4319 | public class ConcurrentHashMapV8<K, V>
4319              if (transformer == null || reducer == null)
4320                  throw new NullPointerException();
4321              return new MapReduceMappingsToDoubleTask<K,V>
4322 <                (map, transformer, basis, reducer);
4322 >                (map, null, -1, null, transformer, basis, reducer);
4323          }
4324  
4325          /**
# Line 4271 | Line 4343 | public class ConcurrentHashMapV8<K, V>
4343              if (transformer == null || reducer == null)
4344                  throw new NullPointerException();
4345              return new MapReduceMappingsToLongTask<K,V>
4346 <                (map, transformer, basis, reducer);
4346 >                (map, null, -1, null, transformer, basis, reducer);
4347          }
4348  
4349          /**
# Line 4294 | Line 4366 | public class ConcurrentHashMapV8<K, V>
4366              if (transformer == null || reducer == null)
4367                  throw new NullPointerException();
4368              return new MapReduceMappingsToIntTask<K,V>
4369 <                (map, transformer, basis, reducer);
4369 >                (map, null, -1, null, transformer, basis, reducer);
4370          }
4371  
4372          /**
# Line 4309 | Line 4381 | public class ConcurrentHashMapV8<K, V>
4381              (ConcurrentHashMapV8<K,V> map,
4382               Action<K> action) {
4383              if (action == null) throw new NullPointerException();
4384 <            return new ForEachKeyTask<K,V>(map, action);
4384 >            return new ForEachKeyTask<K,V>(map, null, -1, null, action);
4385          }
4386  
4387          /**
# Line 4318 | Line 4390 | public class ConcurrentHashMapV8<K, V>
4390           *
4391           * @param map the map
4392           * @param transformer a function returning the transformation
4393 <         * for an element, or null of there is no transformation (in
4394 <         * which case the action is not applied).
4393 >         * for an element, or null if there is no transformation (in
4394 >         * which case the action is not applied)
4395           * @param action the action
4396           * @return the task
4397           */
# Line 4330 | Line 4402 | public class ConcurrentHashMapV8<K, V>
4402              if (transformer == null || action == null)
4403                  throw new NullPointerException();
4404              return new ForEachTransformedKeyTask<K,V,U>
4405 <                (map, transformer, action);
4405 >                (map, null, -1, null, transformer, action);
4406          }
4407  
4408          /**
# Line 4350 | Line 4422 | public class ConcurrentHashMapV8<K, V>
4422               Fun<? super K, ? extends U> searchFunction) {
4423              if (searchFunction == null) throw new NullPointerException();
4424              return new SearchKeysTask<K,V,U>
4425 <                (map, searchFunction,
4425 >                (map, null, -1, null, searchFunction,
4426                   new AtomicReference<U>());
4427          }
4428  
# Line 4368 | Line 4440 | public class ConcurrentHashMapV8<K, V>
4440               BiFun<? super K, ? super K, ? extends K> reducer) {
4441              if (reducer == null) throw new NullPointerException();
4442              return new ReduceKeysTask<K,V>
4443 <                (map, reducer);
4443 >                (map, null, -1, null, reducer);
4444          }
4445  
4446          /**
# Line 4378 | Line 4450 | public class ConcurrentHashMapV8<K, V>
4450           *
4451           * @param map the map
4452           * @param transformer a function returning the transformation
4453 <         * for an element, or null of there is no transformation (in
4453 >         * for an element, or null if there is no transformation (in
4454           * which case it is not combined).
4455           * @param reducer a commutative associative combining function
4456           * @return the task
# Line 4390 | Line 4462 | public class ConcurrentHashMapV8<K, V>
4462              if (transformer == null || reducer == null)
4463                  throw new NullPointerException();
4464              return new MapReduceKeysTask<K,V,U>
4465 <                (map, transformer, reducer);
4465 >                (map, null, -1, null, transformer, reducer);
4466          }
4467  
4468          /**
# Line 4414 | Line 4486 | public class ConcurrentHashMapV8<K, V>
4486              if (transformer == null || reducer == null)
4487                  throw new NullPointerException();
4488              return new MapReduceKeysToDoubleTask<K,V>
4489 <                (map, transformer, basis, reducer);
4489 >                (map, null, -1, null, transformer, basis, reducer);
4490          }
4491  
4492          /**
# Line 4438 | Line 4510 | public class ConcurrentHashMapV8<K, V>
4510              if (transformer == null || reducer == null)
4511                  throw new NullPointerException();
4512              return new MapReduceKeysToLongTask<K,V>
4513 <                (map, transformer, basis, reducer);
4513 >                (map, null, -1, null, transformer, basis, reducer);
4514          }
4515  
4516          /**
# Line 4462 | Line 4534 | public class ConcurrentHashMapV8<K, V>
4534              if (transformer == null || reducer == null)
4535                  throw new NullPointerException();
4536              return new MapReduceKeysToIntTask<K,V>
4537 <                (map, transformer, basis, reducer);
4537 >                (map, null, -1, null, transformer, basis, reducer);
4538          }
4539  
4540          /**
# Line 4476 | Line 4548 | public class ConcurrentHashMapV8<K, V>
4548              (ConcurrentHashMapV8<K,V> map,
4549               Action<V> action) {
4550              if (action == null) throw new NullPointerException();
4551 <            return new ForEachValueTask<K,V>(map, action);
4551 >            return new ForEachValueTask<K,V>(map, null, -1, null, action);
4552          }
4553  
4554          /**
# Line 4485 | Line 4557 | public class ConcurrentHashMapV8<K, V>
4557           *
4558           * @param map the map
4559           * @param transformer a function returning the transformation
4560 <         * for an element, or null of there is no transformation (in
4561 <         * which case the action is not applied).
4560 >         * for an element, or null if there is no transformation (in
4561 >         * which case the action is not applied)
4562           * @param action the action
4563           */
4564          public static <K,V,U> ForkJoinTask<Void> forEachValue
# Line 4496 | Line 4568 | public class ConcurrentHashMapV8<K, V>
4568              if (transformer == null || action == null)
4569                  throw new NullPointerException();
4570              return new ForEachTransformedValueTask<K,V,U>
4571 <                (map, transformer, action);
4571 >                (map, null, -1, null, transformer, action);
4572          }
4573  
4574          /**
# Line 4510 | Line 4582 | public class ConcurrentHashMapV8<K, V>
4582           * @param searchFunction a function returning a non-null
4583           * result on success, else null
4584           * @return the task
4513         *
4585           */
4586          public static <K,V,U> ForkJoinTask<U> searchValues
4587              (ConcurrentHashMapV8<K,V> map,
4588               Fun<? super V, ? extends U> searchFunction) {
4589              if (searchFunction == null) throw new NullPointerException();
4590              return new SearchValuesTask<K,V,U>
4591 <                (map, searchFunction,
4591 >                (map, null, -1, null, searchFunction,
4592                   new AtomicReference<U>());
4593          }
4594  
# Line 4535 | Line 4606 | public class ConcurrentHashMapV8<K, V>
4606               BiFun<? super V, ? super V, ? extends V> reducer) {
4607              if (reducer == null) throw new NullPointerException();
4608              return new ReduceValuesTask<K,V>
4609 <                (map, reducer);
4609 >                (map, null, -1, null, reducer);
4610          }
4611  
4612          /**
# Line 4545 | Line 4616 | public class ConcurrentHashMapV8<K, V>
4616           *
4617           * @param map the map
4618           * @param transformer a function returning the transformation
4619 <         * for an element, or null of there is no transformation (in
4619 >         * for an element, or null if there is no transformation (in
4620           * which case it is not combined).
4621           * @param reducer a commutative associative combining function
4622           * @return the task
# Line 4557 | Line 4628 | public class ConcurrentHashMapV8<K, V>
4628              if (transformer == null || reducer == null)
4629                  throw new NullPointerException();
4630              return new MapReduceValuesTask<K,V,U>
4631 <                (map, transformer, reducer);
4631 >                (map, null, -1, null, transformer, reducer);
4632          }
4633  
4634          /**
# Line 4581 | Line 4652 | public class ConcurrentHashMapV8<K, V>
4652              if (transformer == null || reducer == null)
4653                  throw new NullPointerException();
4654              return new MapReduceValuesToDoubleTask<K,V>
4655 <                (map, transformer, basis, reducer);
4655 >                (map, null, -1, null, transformer, basis, reducer);
4656          }
4657  
4658          /**
# Line 4605 | Line 4676 | public class ConcurrentHashMapV8<K, V>
4676              if (transformer == null || reducer == null)
4677                  throw new NullPointerException();
4678              return new MapReduceValuesToLongTask<K,V>
4679 <                (map, transformer, basis, reducer);
4679 >                (map, null, -1, null, transformer, basis, reducer);
4680          }
4681  
4682          /**
# Line 4629 | Line 4700 | public class ConcurrentHashMapV8<K, V>
4700              if (transformer == null || reducer == null)
4701                  throw new NullPointerException();
4702              return new MapReduceValuesToIntTask<K,V>
4703 <                (map, transformer, basis, reducer);
4703 >                (map, null, -1, null, transformer, basis, reducer);
4704          }
4705  
4706          /**
# Line 4643 | Line 4714 | public class ConcurrentHashMapV8<K, V>
4714              (ConcurrentHashMapV8<K,V> map,
4715               Action<Map.Entry<K,V>> action) {
4716              if (action == null) throw new NullPointerException();
4717 <            return new ForEachEntryTask<K,V>(map, action);
4717 >            return new ForEachEntryTask<K,V>(map, null, -1, null, action);
4718          }
4719  
4720          /**
# Line 4652 | Line 4723 | public class ConcurrentHashMapV8<K, V>
4723           *
4724           * @param map the map
4725           * @param transformer a function returning the transformation
4726 <         * for an element, or null of there is no transformation (in
4727 <         * which case the action is not applied).
4726 >         * for an element, or null if there is no transformation (in
4727 >         * which case the action is not applied)
4728           * @param action the action
4729           */
4730          public static <K,V,U> ForkJoinTask<Void> forEachEntry
# Line 4663 | Line 4734 | public class ConcurrentHashMapV8<K, V>
4734              if (transformer == null || action == null)
4735                  throw new NullPointerException();
4736              return new ForEachTransformedEntryTask<K,V,U>
4737 <                (map, transformer, action);
4737 >                (map, null, -1, null, transformer, action);
4738          }
4739  
4740          /**
# Line 4677 | Line 4748 | public class ConcurrentHashMapV8<K, V>
4748           * @param searchFunction a function returning a non-null
4749           * result on success, else null
4750           * @return the task
4680         *
4751           */
4752          public static <K,V,U> ForkJoinTask<U> searchEntries
4753              (ConcurrentHashMapV8<K,V> map,
4754               Fun<Map.Entry<K,V>, ? extends U> searchFunction) {
4755              if (searchFunction == null) throw new NullPointerException();
4756              return new SearchEntriesTask<K,V,U>
4757 <                (map, searchFunction,
4757 >                (map, null, -1, null, searchFunction,
4758                   new AtomicReference<U>());
4759          }
4760  
# Line 4702 | Line 4772 | public class ConcurrentHashMapV8<K, V>
4772               BiFun<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) {
4773              if (reducer == null) throw new NullPointerException();
4774              return new ReduceEntriesTask<K,V>
4775 <                (map, reducer);
4775 >                (map, null, -1, null, reducer);
4776          }
4777  
4778          /**
# Line 4712 | Line 4782 | public class ConcurrentHashMapV8<K, V>
4782           *
4783           * @param map the map
4784           * @param transformer a function returning the transformation
4785 <         * for an element, or null of there is no transformation (in
4785 >         * for an element, or null if there is no transformation (in
4786           * which case it is not combined).
4787           * @param reducer a commutative associative combining function
4788           * @return the task
# Line 4724 | Line 4794 | public class ConcurrentHashMapV8<K, V>
4794              if (transformer == null || reducer == null)
4795                  throw new NullPointerException();
4796              return new MapReduceEntriesTask<K,V,U>
4797 <                (map, transformer, reducer);
4797 >                (map, null, -1, null, transformer, reducer);
4798          }
4799  
4800          /**
# Line 4748 | Line 4818 | public class ConcurrentHashMapV8<K, V>
4818              if (transformer == null || reducer == null)
4819                  throw new NullPointerException();
4820              return new MapReduceEntriesToDoubleTask<K,V>
4821 <                (map, transformer, basis, reducer);
4821 >                (map, null, -1, null, transformer, basis, reducer);
4822          }
4823  
4824          /**
# Line 4772 | Line 4842 | public class ConcurrentHashMapV8<K, V>
4842              if (transformer == null || reducer == null)
4843                  throw new NullPointerException();
4844              return new MapReduceEntriesToLongTask<K,V>
4845 <                (map, transformer, basis, reducer);
4845 >                (map, null, -1, null, transformer, basis, reducer);
4846          }
4847  
4848          /**
# Line 4796 | Line 4866 | public class ConcurrentHashMapV8<K, V>
4866              if (transformer == null || reducer == null)
4867                  throw new NullPointerException();
4868              return new MapReduceEntriesToIntTask<K,V>
4869 <                (map, transformer, basis, reducer);
4869 >                (map, null, -1, null, transformer, basis, reducer);
4870          }
4871      }
4872  
# Line 4815 | Line 4885 | public class ConcurrentHashMapV8<K, V>
4885       */
4886      @SuppressWarnings("serial") static abstract class BulkTask<K,V,R> extends Traverser<K,V,R> {
4887          final BulkTask<K,V,?> parent;  // completion target
4888 <        int batch;                     // split control
4888 >        int batch;                     // split control; -1 for unknown
4889          int pending;                   // completion control
4890  
4891 <        /** Constructor for root tasks */
4892 <        BulkTask(ConcurrentHashMapV8<K,V> map) {
4891 >        BulkTask(ConcurrentHashMapV8<K,V> map, BulkTask<K,V,?> parent,
4892 >                 int batch) {
4893              super(map);
4824            this.parent = null;
4825            this.batch = -1; // force call to batch() on execution
4826        }
4827
4828        /** Constructor for subtasks */
4829        BulkTask(BulkTask<K,V,?> parent, int batch) {
4830            super(parent);
4894              this.parent = parent;
4895              this.batch = batch;
4896 +            if (parent != null && map != null) { // split parent
4897 +                Node[] t;
4898 +                if ((t = parent.tab) == null &&
4899 +                    (t = parent.tab = map.table) != null)
4900 +                    parent.baseLimit = parent.baseSize = t.length;
4901 +                this.tab = t;
4902 +                this.baseSize = parent.baseSize;
4903 +                int hi = this.baseLimit = parent.baseLimit;
4904 +                parent.baseLimit = this.index = this.baseIndex =
4905 +                    (hi + parent.baseIndex + 1) >>> 1;
4906 +            }
4907          }
4908  
4909          // FJ methods
# Line 4893 | Line 4967 | public class ConcurrentHashMapV8<K, V>
4967           * dividing by two anyway.
4968           */
4969          final int batch() {
4970 <            int b = batch;
4971 <            if (b < 0) {
4972 <                long n = map.counter.sum();
4973 <                int sp = getPool().getParallelism() << 3; // slack of 8
4974 <                b = batch = (n <= 0L) ? 0 : (n < (long)sp) ? (int)n : sp;
4970 >            ConcurrentHashMapV8<K, V> m; int b; Node[] t;  ForkJoinPool pool;
4971 >            if ((b = batch) < 0 && (m = map) != null) { // force initialization
4972 >                if ((t = tab) == null && (t = tab = m.table) != null)
4973 >                    baseLimit = baseSize = t.length;
4974 >                if (t != null) {
4975 >                    long n = m.counter.sum();
4976 >                    int par = (pool = getPool()) == null?
4977 >                        ForkJoinPool.getCommonPoolParallelism() :
4978 >                        pool.getParallelism();
4979 >                    int sp = par << 3; // slack of 8
4980 >                    b = batch = (n <= 0L) ? 0 : (n < (long)sp) ? (int)n : sp;
4981 >                }
4982              }
4983              return b;
4984          }
# Line 4932 | Line 5013 | public class ConcurrentHashMapV8<K, V>
5013      @SuppressWarnings("serial") static final class ForEachKeyTask<K,V>
5014          extends BulkTask<K,V,Void> {
5015          final Action<K> action;
5016 +        ForEachKeyTask<K,V> nextRight;
5017          ForEachKeyTask
5018 <            (ConcurrentHashMapV8<K,V> m,
5018 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5019 >             ForEachKeyTask<K,V> nextRight,
5020               Action<K> action) {
5021 <            super(m);
5022 <            this.action = action;
4940 <        }
4941 <        ForEachKeyTask
4942 <            (BulkTask<K,V,?> p, int b,
4943 <             Action<K> action) {
4944 <            super(p, b);
5021 >            super(m, p, b);
5022 >            this.nextRight = nextRight;
5023              this.action = action;
5024          }
5025          @SuppressWarnings("unchecked") public final boolean exec() {
5026              final Action<K> action = this.action;
5027              if (action == null)
5028                  return abortOnNullFunction();
5029 +            ForEachKeyTask<K,V> rights = null;
5030              try {
5031                  int b = batch(), c;
5032                  while (b > 1 && baseIndex != baseLimit) {
5033                      do {} while (!casPending(c = pending, c+1));
5034 <                    new ForEachKeyTask<K,V>(this, b >>>= 1, action).fork();
5034 >                    (rights = new ForEachKeyTask<K,V>
5035 >                     (map, this, b >>>= 1, rights, action)).fork();
5036                  }
5037                  while (advance() != null)
5038                      action.apply((K)nextKey);
# Line 4960 | Line 5040 | public class ConcurrentHashMapV8<K, V>
5040              } catch (Throwable ex) {
5041                  return tryCompleteComputation(ex);
5042              }
5043 +            while (rights != null && rights.tryUnfork()) {
5044 +                rights.exec();
5045 +                rights = rights.nextRight;
5046 +            }
5047              return false;
5048          }
5049      }
5050  
5051      @SuppressWarnings("serial") static final class ForEachValueTask<K,V>
5052          extends BulkTask<K,V,Void> {
5053 +        ForEachValueTask<K,V> nextRight;
5054          final Action<V> action;
5055          ForEachValueTask
5056 <            (ConcurrentHashMapV8<K,V> m,
5056 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5057 >             ForEachValueTask<K,V> nextRight,
5058               Action<V> action) {
5059 <            super(m);
5060 <            this.action = action;
4975 <        }
4976 <        ForEachValueTask
4977 <            (BulkTask<K,V,?> p, int b,
4978 <             Action<V> action) {
4979 <            super(p, b);
5059 >            super(m, p, b);
5060 >            this.nextRight = nextRight;
5061              this.action = action;
5062          }
5063          @SuppressWarnings("unchecked") public final boolean exec() {
5064              final Action<V> action = this.action;
5065              if (action == null)
5066                  return abortOnNullFunction();
5067 +            ForEachValueTask<K,V> rights = null;
5068              try {
5069                  int b = batch(), c;
5070                  while (b > 1 && baseIndex != baseLimit) {
5071                      do {} while (!casPending(c = pending, c+1));
5072 <                    new ForEachValueTask<K,V>(this, b >>>= 1, action).fork();
5072 >                    (rights = new ForEachValueTask<K,V>
5073 >                     (map, this, b >>>= 1, rights, action)).fork();
5074                  }
5075                  Object v;
5076                  while ((v = advance()) != null)
# Line 4996 | Line 5079 | public class ConcurrentHashMapV8<K, V>
5079              } catch (Throwable ex) {
5080                  return tryCompleteComputation(ex);
5081              }
5082 +            while (rights != null && rights.tryUnfork()) {
5083 +                rights.exec();
5084 +                rights = rights.nextRight;
5085 +            }
5086              return false;
5087          }
5088      }
5089  
5090      @SuppressWarnings("serial") static final class ForEachEntryTask<K,V>
5091          extends BulkTask<K,V,Void> {
5092 +        ForEachEntryTask<K,V> nextRight;
5093          final Action<Entry<K,V>> action;
5094          ForEachEntryTask
5095 <            (ConcurrentHashMapV8<K,V> m,
5095 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5096 >             ForEachEntryTask<K,V> nextRight,
5097               Action<Entry<K,V>> action) {
5098 <            super(m);
5099 <            this.action = action;
5011 <        }
5012 <        ForEachEntryTask
5013 <            (BulkTask<K,V,?> p, int b,
5014 <             Action<Entry<K,V>> action) {
5015 <            super(p, b);
5098 >            super(m, p, b);
5099 >            this.nextRight = nextRight;
5100              this.action = action;
5101          }
5102          @SuppressWarnings("unchecked") public final boolean exec() {
5103              final Action<Entry<K,V>> action = this.action;
5104              if (action == null)
5105                  return abortOnNullFunction();
5106 +            ForEachEntryTask<K,V> rights = null;
5107              try {
5108                  int b = batch(), c;
5109                  while (b > 1 && baseIndex != baseLimit) {
5110                      do {} while (!casPending(c = pending, c+1));
5111 <                    new ForEachEntryTask<K,V>(this, b >>>= 1, action).fork();
5111 >                    (rights = new ForEachEntryTask<K,V>
5112 >                     (map, this, b >>>= 1, rights, action)).fork();
5113                  }
5114                  Object v;
5115                  while ((v = advance()) != null)
# Line 5032 | Line 5118 | public class ConcurrentHashMapV8<K, V>
5118              } catch (Throwable ex) {
5119                  return tryCompleteComputation(ex);
5120              }
5121 +            while (rights != null && rights.tryUnfork()) {
5122 +                rights.exec();
5123 +                rights = rights.nextRight;
5124 +            }
5125              return false;
5126          }
5127      }
5128  
5129      @SuppressWarnings("serial") static final class ForEachMappingTask<K,V>
5130          extends BulkTask<K,V,Void> {
5131 +        ForEachMappingTask<K,V> nextRight;
5132          final BiAction<K,V> action;
5133          ForEachMappingTask
5134 <            (ConcurrentHashMapV8<K,V> m,
5134 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5135 >             ForEachMappingTask<K,V> nextRight,
5136               BiAction<K,V> action) {
5137 <            super(m);
5137 >            super(m, p, b);
5138 >            this.nextRight = nextRight;
5139              this.action = action;
5140          }
5048        ForEachMappingTask
5049            (BulkTask<K,V,?> p, int b,
5050             BiAction<K,V> action) {
5051            super(p, b);
5052            this.action = action;
5053        }
5054
5141          @SuppressWarnings("unchecked") public final boolean exec() {
5142              final BiAction<K,V> action = this.action;
5143              if (action == null)
5144                  return abortOnNullFunction();
5145 +            ForEachMappingTask<K,V> rights = null;
5146              try {
5147                  int b = batch(), c;
5148                  while (b > 1 && baseIndex != baseLimit) {
5149                      do {} while (!casPending(c = pending, c+1));
5150 <                    new ForEachMappingTask<K,V>(this, b >>>= 1,
5151 <                                                action).fork();
5150 >                    (rights = new ForEachMappingTask<K,V>
5151 >                     (map, this, b >>>= 1, rights, action)).fork();
5152                  }
5153                  Object v;
5154                  while ((v = advance()) != null)
# Line 5070 | Line 5157 | public class ConcurrentHashMapV8<K, V>
5157              } catch (Throwable ex) {
5158                  return tryCompleteComputation(ex);
5159              }
5160 +            while (rights != null && rights.tryUnfork()) {
5161 +                rights.exec();
5162 +                rights = rights.nextRight;
5163 +            }
5164              return false;
5165          }
5166      }
5167  
5168      @SuppressWarnings("serial") static final class ForEachTransformedKeyTask<K,V,U>
5169          extends BulkTask<K,V,Void> {
5170 +        ForEachTransformedKeyTask<K,V,U> nextRight;
5171          final Fun<? super K, ? extends U> transformer;
5172          final Action<U> action;
5173          ForEachTransformedKeyTask
5174 <            (ConcurrentHashMapV8<K,V> m,
5174 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5175 >             ForEachTransformedKeyTask<K,V,U> nextRight,
5176               Fun<? super K, ? extends U> transformer,
5177               Action<U> action) {
5178 <            super(m);
5178 >            super(m, p, b);
5179 >            this.nextRight = nextRight;
5180              this.transformer = transformer;
5181              this.action = action;
5182  
5183          }
5090        ForEachTransformedKeyTask
5091            (BulkTask<K,V,?> p, int b,
5092             Fun<? super K, ? extends U> transformer,
5093             Action<U> action) {
5094            super(p, b);
5095            this.transformer = transformer;
5096            this.action = action;
5097        }
5184          @SuppressWarnings("unchecked") public final boolean exec() {
5185              final Fun<? super K, ? extends U> transformer =
5186                  this.transformer;
5187              final Action<U> action = this.action;
5188              if (transformer == null || action == null)
5189                  return abortOnNullFunction();
5190 +            ForEachTransformedKeyTask<K,V,U> rights = null;
5191              try {
5192                  int b = batch(), c;
5193                  while (b > 1 && baseIndex != baseLimit) {
5194                      do {} while (!casPending(c = pending, c+1));
5195 <                    new ForEachTransformedKeyTask<K,V,U>
5196 <                        (this, b >>>= 1, transformer, action).fork();
5195 >                    (rights = new ForEachTransformedKeyTask<K,V,U>
5196 >                     (map, this, b >>>= 1, rights, transformer, action)).fork();
5197                  }
5198                  U u;
5199                  while (advance() != null) {
# Line 5117 | Line 5204 | public class ConcurrentHashMapV8<K, V>
5204              } catch (Throwable ex) {
5205                  return tryCompleteComputation(ex);
5206              }
5207 +            while (rights != null && rights.tryUnfork()) {
5208 +                rights.exec();
5209 +                rights = rights.nextRight;
5210 +            }
5211              return false;
5212          }
5213      }
5214  
5215      @SuppressWarnings("serial") static final class ForEachTransformedValueTask<K,V,U>
5216          extends BulkTask<K,V,Void> {
5217 +        ForEachTransformedValueTask<K,V,U> nextRight;
5218          final Fun<? super V, ? extends U> transformer;
5219          final Action<U> action;
5220          ForEachTransformedValueTask
5221 <            (ConcurrentHashMapV8<K,V> m,
5221 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5222 >             ForEachTransformedValueTask<K,V,U> nextRight,
5223               Fun<? super V, ? extends U> transformer,
5224               Action<U> action) {
5225 <            super(m);
5225 >            super(m, p, b);
5226 >            this.nextRight = nextRight;
5227              this.transformer = transformer;
5228              this.action = action;
5229  
5230          }
5137        ForEachTransformedValueTask
5138            (BulkTask<K,V,?> p, int b,
5139             Fun<? super V, ? extends U> transformer,
5140             Action<U> action) {
5141            super(p, b);
5142            this.transformer = transformer;
5143            this.action = action;
5144        }
5231          @SuppressWarnings("unchecked") public final boolean exec() {
5232              final Fun<? super V, ? extends U> transformer =
5233                  this.transformer;
5234              final Action<U> action = this.action;
5235              if (transformer == null || action == null)
5236                  return abortOnNullFunction();
5237 +            ForEachTransformedValueTask<K,V,U> rights = null;
5238              try {
5239                  int b = batch(), c;
5240                  while (b > 1 && baseIndex != baseLimit) {
5241                      do {} while (!casPending(c = pending, c+1));
5242 <                    new ForEachTransformedValueTask<K,V,U>
5243 <                        (this, b >>>= 1, transformer, action).fork();
5242 >                    (rights = new ForEachTransformedValueTask<K,V,U>
5243 >                     (map, this, b >>>= 1, rights, transformer, action)).fork();
5244                  }
5245                  Object v; U u;
5246                  while ((v = advance()) != null) {
# Line 5164 | Line 5251 | public class ConcurrentHashMapV8<K, V>
5251              } catch (Throwable ex) {
5252                  return tryCompleteComputation(ex);
5253              }
5254 +            while (rights != null && rights.tryUnfork()) {
5255 +                rights.exec();
5256 +                rights = rights.nextRight;
5257 +            }
5258              return false;
5259          }
5260      }
5261  
5262      @SuppressWarnings("serial") static final class ForEachTransformedEntryTask<K,V,U>
5263          extends BulkTask<K,V,Void> {
5264 +        ForEachTransformedEntryTask<K,V,U> nextRight;
5265          final Fun<Map.Entry<K,V>, ? extends U> transformer;
5266          final Action<U> action;
5267          ForEachTransformedEntryTask
5268 <            (ConcurrentHashMapV8<K,V> m,
5268 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5269 >             ForEachTransformedEntryTask<K,V,U> nextRight,
5270               Fun<Map.Entry<K,V>, ? extends U> transformer,
5271               Action<U> action) {
5272 <            super(m);
5272 >            super(m, p, b);
5273 >            this.nextRight = nextRight;
5274              this.transformer = transformer;
5275              this.action = action;
5276  
5277          }
5184        ForEachTransformedEntryTask
5185            (BulkTask<K,V,?> p, int b,
5186             Fun<Map.Entry<K,V>, ? extends U> transformer,
5187             Action<U> action) {
5188            super(p, b);
5189            this.transformer = transformer;
5190            this.action = action;
5191        }
5278          @SuppressWarnings("unchecked") public final boolean exec() {
5279              final Fun<Map.Entry<K,V>, ? extends U> transformer =
5280                  this.transformer;
5281              final Action<U> action = this.action;
5282              if (transformer == null || action == null)
5283                  return abortOnNullFunction();
5284 +            ForEachTransformedEntryTask<K,V,U> rights = null;
5285              try {
5286                  int b = batch(), c;
5287                  while (b > 1 && baseIndex != baseLimit) {
5288                      do {} while (!casPending(c = pending, c+1));
5289 <                    new ForEachTransformedEntryTask<K,V,U>
5290 <                        (this, b >>>= 1, transformer, action).fork();
5289 >                    (rights = new ForEachTransformedEntryTask<K,V,U>
5290 >                     (map, this, b >>>= 1, rights, transformer, action)).fork();
5291                  }
5292                  Object v; U u;
5293                  while ((v = advance()) != null) {
# Line 5211 | Line 5298 | public class ConcurrentHashMapV8<K, V>
5298              } catch (Throwable ex) {
5299                  return tryCompleteComputation(ex);
5300              }
5301 +            while (rights != null && rights.tryUnfork()) {
5302 +                rights.exec();
5303 +                rights = rights.nextRight;
5304 +            }
5305              return false;
5306          }
5307      }
5308  
5309      @SuppressWarnings("serial") static final class ForEachTransformedMappingTask<K,V,U>
5310          extends BulkTask<K,V,Void> {
5311 +        ForEachTransformedMappingTask<K,V,U> nextRight;
5312          final BiFun<? super K, ? super V, ? extends U> transformer;
5313          final Action<U> action;
5314          ForEachTransformedMappingTask
5315 <            (ConcurrentHashMapV8<K,V> m,
5315 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5316 >             ForEachTransformedMappingTask<K,V,U> nextRight,
5317               BiFun<? super K, ? super V, ? extends U> transformer,
5318               Action<U> action) {
5319 <            super(m);
5319 >            super(m, p, b);
5320 >            this.nextRight = nextRight;
5321              this.transformer = transformer;
5322              this.action = action;
5323  
5324          }
5231        ForEachTransformedMappingTask
5232            (BulkTask<K,V,?> p, int b,
5233             BiFun<? super K, ? super V, ? extends U> transformer,
5234             Action<U> action) {
5235            super(p, b);
5236            this.transformer = transformer;
5237            this.action = action;
5238        }
5325          @SuppressWarnings("unchecked") public final boolean exec() {
5326              final BiFun<? super K, ? super V, ? extends U> transformer =
5327                  this.transformer;
5328              final Action<U> action = this.action;
5329              if (transformer == null || action == null)
5330                  return abortOnNullFunction();
5331 +            ForEachTransformedMappingTask<K,V,U> rights = null;
5332              try {
5333                  int b = batch(), c;
5334                  while (b > 1 && baseIndex != baseLimit) {
5335                      do {} while (!casPending(c = pending, c+1));
5336 <                    new ForEachTransformedMappingTask<K,V,U>
5337 <                        (this, b >>>= 1, transformer, action).fork();
5336 >                    (rights = new ForEachTransformedMappingTask<K,V,U>
5337 >                     (map, this, b >>>= 1, rights, transformer, action)).fork();
5338                  }
5339                  Object v; U u;
5340                  while ((v = advance()) != null) {
# Line 5258 | Line 5345 | public class ConcurrentHashMapV8<K, V>
5345              } catch (Throwable ex) {
5346                  return tryCompleteComputation(ex);
5347              }
5348 +            while (rights != null && rights.tryUnfork()) {
5349 +                rights.exec();
5350 +                rights = rights.nextRight;
5351 +            }
5352              return false;
5353          }
5354      }
5355  
5356      @SuppressWarnings("serial") static final class SearchKeysTask<K,V,U>
5357          extends BulkTask<K,V,U> {
5358 +        SearchKeysTask<K,V,U> nextRight;
5359          final Fun<? super K, ? extends U> searchFunction;
5360          final AtomicReference<U> result;
5361          SearchKeysTask
5362 <            (ConcurrentHashMapV8<K,V> m,
5363 <             Fun<? super K, ? extends U> searchFunction,
5272 <             AtomicReference<U> result) {
5273 <            super(m);
5274 <            this.searchFunction = searchFunction; this.result = result;
5275 <        }
5276 <        SearchKeysTask
5277 <            (BulkTask<K,V,?> p, int b,
5362 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5363 >             SearchKeysTask<K,V,U> nextRight,
5364               Fun<? super K, ? extends U> searchFunction,
5365               AtomicReference<U> result) {
5366 <            super(p, b);
5366 >            super(m, p, b);
5367 >            this.nextRight = nextRight;
5368              this.searchFunction = searchFunction; this.result = result;
5369          }
5370          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5286 | Line 5373 | public class ConcurrentHashMapV8<K, V>
5373                  this.searchFunction;
5374              if (searchFunction == null || result == null)
5375                  return abortOnNullFunction();
5376 +            SearchKeysTask<K,V,U> rights = null;
5377              try {
5378                  int b = batch(), c;
5379                  while (b > 1 && baseIndex != baseLimit && result.get() == null) {
5380                      do {} while (!casPending(c = pending, c+1));
5381 <                    new SearchKeysTask<K,V,U>(this, b >>>= 1,
5382 <                                              searchFunction, result).fork();
5381 >                    (rights = new SearchKeysTask<K,V,U>
5382 >                     (map, this, b >>>= 1, rights, searchFunction, result)).fork();
5383                  }
5384                  U u;
5385                  while (result.get() == null && advance() != null) {
# Line 5305 | Line 5393 | public class ConcurrentHashMapV8<K, V>
5393              } catch (Throwable ex) {
5394                  return tryCompleteComputation(ex);
5395              }
5396 +            while (rights != null && result.get() == null && rights.tryUnfork()) {
5397 +                rights.exec();
5398 +                rights = rights.nextRight;
5399 +            }
5400              return false;
5401          }
5402          public final U getRawResult() { return result.get(); }
# Line 5312 | Line 5404 | public class ConcurrentHashMapV8<K, V>
5404  
5405      @SuppressWarnings("serial") static final class SearchValuesTask<K,V,U>
5406          extends BulkTask<K,V,U> {
5407 +        SearchValuesTask<K,V,U> nextRight;
5408          final Fun<? super V, ? extends U> searchFunction;
5409          final AtomicReference<U> result;
5410          SearchValuesTask
5411 <            (ConcurrentHashMapV8<K,V> m,
5411 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5412 >             SearchValuesTask<K,V,U> nextRight,
5413               Fun<? super V, ? extends U> searchFunction,
5414               AtomicReference<U> result) {
5415 <            super(m);
5416 <            this.searchFunction = searchFunction; this.result = result;
5323 <        }
5324 <        SearchValuesTask
5325 <            (BulkTask<K,V,?> p, int b,
5326 <             Fun<? super V, ? extends U> searchFunction,
5327 <             AtomicReference<U> result) {
5328 <            super(p, b);
5415 >            super(m, p, b);
5416 >            this.nextRight = nextRight;
5417              this.searchFunction = searchFunction; this.result = result;
5418          }
5419          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5334 | Line 5422 | public class ConcurrentHashMapV8<K, V>
5422                  this.searchFunction;
5423              if (searchFunction == null || result == null)
5424                  return abortOnNullFunction();
5425 +            SearchValuesTask<K,V,U> rights = null;
5426              try {
5427                  int b = batch(), c;
5428                  while (b > 1 && baseIndex != baseLimit && result.get() == null) {
5429                      do {} while (!casPending(c = pending, c+1));
5430 <                    new SearchValuesTask<K,V,U>(this, b >>>= 1,
5431 <                                                searchFunction, result).fork();
5430 >                    (rights = new SearchValuesTask<K,V,U>
5431 >                     (map, this, b >>>= 1, rights, searchFunction, result)).fork();
5432                  }
5433                  Object v; U u;
5434                  while (result.get() == null && (v = advance()) != null) {
# Line 5353 | Line 5442 | public class ConcurrentHashMapV8<K, V>
5442              } catch (Throwable ex) {
5443                  return tryCompleteComputation(ex);
5444              }
5445 +            while (rights != null && result.get() == null && rights.tryUnfork()) {
5446 +                rights.exec();
5447 +                rights = rights.nextRight;
5448 +            }
5449              return false;
5450          }
5451          public final U getRawResult() { return result.get(); }
# Line 5360 | Line 5453 | public class ConcurrentHashMapV8<K, V>
5453  
5454      @SuppressWarnings("serial") static final class SearchEntriesTask<K,V,U>
5455          extends BulkTask<K,V,U> {
5456 +        SearchEntriesTask<K,V,U> nextRight;
5457          final Fun<Entry<K,V>, ? extends U> searchFunction;
5458          final AtomicReference<U> result;
5459          SearchEntriesTask
5460 <            (ConcurrentHashMapV8<K,V> m,
5461 <             Fun<Entry<K,V>, ? extends U> searchFunction,
5368 <             AtomicReference<U> result) {
5369 <            super(m);
5370 <            this.searchFunction = searchFunction; this.result = result;
5371 <        }
5372 <        SearchEntriesTask
5373 <            (BulkTask<K,V,?> p, int b,
5460 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5461 >             SearchEntriesTask<K,V,U> nextRight,
5462               Fun<Entry<K,V>, ? extends U> searchFunction,
5463               AtomicReference<U> result) {
5464 <            super(p, b);
5464 >            super(m, p, b);
5465 >            this.nextRight = nextRight;
5466              this.searchFunction = searchFunction; this.result = result;
5467          }
5468          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5382 | Line 5471 | public class ConcurrentHashMapV8<K, V>
5471                  this.searchFunction;
5472              if (searchFunction == null || result == null)
5473                  return abortOnNullFunction();
5474 +            SearchEntriesTask<K,V,U> rights = null;
5475              try {
5476                  int b = batch(), c;
5477                  while (b > 1 && baseIndex != baseLimit && result.get() == null) {
5478                      do {} while (!casPending(c = pending, c+1));
5479 <                    new SearchEntriesTask<K,V,U>(this, b >>>= 1,
5480 <                                                 searchFunction, result).fork();
5479 >                    (rights = new SearchEntriesTask<K,V,U>
5480 >                     (map, this, b >>>= 1, rights, searchFunction, result)).fork();
5481                  }
5482                  Object v; U u;
5483                  while (result.get() == null && (v = advance()) != null) {
# Line 5401 | Line 5491 | public class ConcurrentHashMapV8<K, V>
5491              } catch (Throwable ex) {
5492                  return tryCompleteComputation(ex);
5493              }
5494 +            while (rights != null && result.get() == null && rights.tryUnfork()) {
5495 +                rights.exec();
5496 +                rights = rights.nextRight;
5497 +            }
5498              return false;
5499          }
5500          public final U getRawResult() { return result.get(); }
# Line 5408 | Line 5502 | public class ConcurrentHashMapV8<K, V>
5502  
5503      @SuppressWarnings("serial") static final class SearchMappingsTask<K,V,U>
5504          extends BulkTask<K,V,U> {
5505 +        SearchMappingsTask<K,V,U> nextRight;
5506          final BiFun<? super K, ? super V, ? extends U> searchFunction;
5507          final AtomicReference<U> result;
5508          SearchMappingsTask
5509 <            (ConcurrentHashMapV8<K,V> m,
5510 <             BiFun<? super K, ? super V, ? extends U> searchFunction,
5416 <             AtomicReference<U> result) {
5417 <            super(m);
5418 <            this.searchFunction = searchFunction; this.result = result;
5419 <        }
5420 <        SearchMappingsTask
5421 <            (BulkTask<K,V,?> p, int b,
5509 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5510 >             SearchMappingsTask<K,V,U> nextRight,
5511               BiFun<? super K, ? super V, ? extends U> searchFunction,
5512               AtomicReference<U> result) {
5513 <            super(p, b);
5513 >            super(m, p, b);
5514 >            this.nextRight = nextRight;
5515              this.searchFunction = searchFunction; this.result = result;
5516          }
5517          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5430 | Line 5520 | public class ConcurrentHashMapV8<K, V>
5520                  this.searchFunction;
5521              if (searchFunction == null || result == null)
5522                  return abortOnNullFunction();
5523 +            SearchMappingsTask<K,V,U> rights = null;
5524              try {
5525                  int b = batch(), c;
5526                  while (b > 1 && baseIndex != baseLimit && result.get() == null) {
5527                      do {} while (!casPending(c = pending, c+1));
5528 <                    new SearchMappingsTask<K,V,U>(this, b >>>= 1,
5529 <                                                  searchFunction, result).fork();
5528 >                    (rights = new SearchMappingsTask<K,V,U>
5529 >                     (map, this, b >>>= 1, rights, searchFunction, result)).fork();
5530                  }
5531                  Object v; U u;
5532                  while (result.get() == null && (v = advance()) != null) {
# Line 5449 | Line 5540 | public class ConcurrentHashMapV8<K, V>
5540              } catch (Throwable ex) {
5541                  return tryCompleteComputation(ex);
5542              }
5543 +            while (rights != null && result.get() == null && rights.tryUnfork()) {
5544 +                rights.exec();
5545 +                rights = rights.nextRight;
5546 +            }
5547              return false;
5548          }
5549          public final U getRawResult() { return result.get(); }
# Line 5460 | Line 5555 | public class ConcurrentHashMapV8<K, V>
5555          K result;
5556          ReduceKeysTask<K,V> rights, nextRight;
5557          ReduceKeysTask
5558 <            (ConcurrentHashMapV8<K,V> m,
5464 <             BiFun<? super K, ? super K, ? extends K> reducer) {
5465 <            super(m);
5466 <            this.reducer = reducer;
5467 <        }
5468 <        ReduceKeysTask
5469 <            (BulkTask<K,V,?> p, int b,
5558 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5559               ReduceKeysTask<K,V> nextRight,
5560               BiFun<? super K, ? super K, ? extends K> reducer) {
5561 <            super(p, b); this.nextRight = nextRight;
5561 >            super(m, p, b); this.nextRight = nextRight;
5562              this.reducer = reducer;
5563          }
5475
5564          @SuppressWarnings("unchecked") public final boolean exec() {
5565              final BiFun<? super K, ? super K, ? extends K> reducer =
5566                  this.reducer;
# Line 5482 | Line 5570 | public class ConcurrentHashMapV8<K, V>
5570                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5571                      do {} while (!casPending(c = pending, c+1));
5572                      (rights = new ReduceKeysTask<K,V>
5573 <                     (this, b >>>= 1, rights, reducer)).fork();
5573 >                     (map, this, b >>>= 1, rights, reducer)).fork();
5574                  }
5575                  K r = null;
5576                  while (advance() != null) {
# Line 5495 | Line 5583 | public class ConcurrentHashMapV8<K, V>
5583                      if ((c = t.pending) == 0) {
5584                          for (s = t.rights; s != null; s = t.rights = s.nextRight) {
5585                              if ((sr = s.result) != null)
5586 <                                t.result = (tr = t.result) == null? sr : reducer.apply(tr, sr);
5586 >                                t.result = ((tr = t.result) == null) ? sr : reducer.apply(tr, sr);
5587                          }
5588                          if ((par = t.parent) == null ||
5589                              !(par instanceof ReduceKeysTask)) {
# Line 5510 | Line 5598 | public class ConcurrentHashMapV8<K, V>
5598              } catch (Throwable ex) {
5599                  return tryCompleteComputation(ex);
5600              }
5601 +            for (ReduceKeysTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
5602 +                s.exec();
5603              return false;
5604          }
5605          public final K getRawResult() { return result; }
# Line 5521 | Line 5611 | public class ConcurrentHashMapV8<K, V>
5611          V result;
5612          ReduceValuesTask<K,V> rights, nextRight;
5613          ReduceValuesTask
5614 <            (ConcurrentHashMapV8<K,V> m,
5525 <             BiFun<? super V, ? super V, ? extends V> reducer) {
5526 <            super(m);
5527 <            this.reducer = reducer;
5528 <        }
5529 <        ReduceValuesTask
5530 <            (BulkTask<K,V,?> p, int b,
5614 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5615               ReduceValuesTask<K,V> nextRight,
5616               BiFun<? super V, ? super V, ? extends V> reducer) {
5617 <            super(p, b); this.nextRight = nextRight;
5617 >            super(m, p, b); this.nextRight = nextRight;
5618              this.reducer = reducer;
5619          }
5536
5620          @SuppressWarnings("unchecked") public final boolean exec() {
5621              final BiFun<? super V, ? super V, ? extends V> reducer =
5622                  this.reducer;
# Line 5543 | Line 5626 | public class ConcurrentHashMapV8<K, V>
5626                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5627                      do {} while (!casPending(c = pending, c+1));
5628                      (rights = new ReduceValuesTask<K,V>
5629 <                     (this, b >>>= 1, rights, reducer)).fork();
5629 >                     (map, this, b >>>= 1, rights, reducer)).fork();
5630                  }
5631                  V r = null;
5632                  Object v;
# Line 5557 | Line 5640 | public class ConcurrentHashMapV8<K, V>
5640                      if ((c = t.pending) == 0) {
5641                          for (s = t.rights; s != null; s = t.rights = s.nextRight) {
5642                              if ((sr = s.result) != null)
5643 <                                t.result = (tr = t.result) == null? sr : reducer.apply(tr, sr);
5643 >                                t.result = ((tr = t.result) == null) ? sr : reducer.apply(tr, sr);
5644                          }
5645                          if ((par = t.parent) == null ||
5646                              !(par instanceof ReduceValuesTask)) {
# Line 5572 | Line 5655 | public class ConcurrentHashMapV8<K, V>
5655              } catch (Throwable ex) {
5656                  return tryCompleteComputation(ex);
5657              }
5658 +            for (ReduceValuesTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
5659 +                s.exec();
5660              return false;
5661          }
5662          public final V getRawResult() { return result; }
# Line 5583 | Line 5668 | public class ConcurrentHashMapV8<K, V>
5668          Map.Entry<K,V> result;
5669          ReduceEntriesTask<K,V> rights, nextRight;
5670          ReduceEntriesTask
5671 <            (ConcurrentHashMapV8<K,V> m,
5587 <             BiFun<Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) {
5588 <            super(m);
5589 <            this.reducer = reducer;
5590 <        }
5591 <        ReduceEntriesTask
5592 <            (BulkTask<K,V,?> p, int b,
5671 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5672               ReduceEntriesTask<K,V> nextRight,
5673 <             BiFun<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) {
5674 <            super(p, b); this.nextRight = nextRight;
5673 >             BiFun<Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer) {
5674 >            super(m, p, b); this.nextRight = nextRight;
5675              this.reducer = reducer;
5676          }
5598
5677          @SuppressWarnings("unchecked") public final boolean exec() {
5678              final BiFun<Map.Entry<K,V>, Map.Entry<K,V>, ? extends Map.Entry<K,V>> reducer =
5679                  this.reducer;
# Line 5605 | Line 5683 | public class ConcurrentHashMapV8<K, V>
5683                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5684                      do {} while (!casPending(c = pending, c+1));
5685                      (rights = new ReduceEntriesTask<K,V>
5686 <                     (this, b >>>= 1, rights, reducer)).fork();
5686 >                     (map, this, b >>>= 1, rights, reducer)).fork();
5687                  }
5688                  Map.Entry<K,V> r = null;
5689                  Object v;
# Line 5619 | Line 5697 | public class ConcurrentHashMapV8<K, V>
5697                      if ((c = t.pending) == 0) {
5698                          for (s = t.rights; s != null; s = t.rights = s.nextRight) {
5699                              if ((sr = s.result) != null)
5700 <                                t.result = (tr = t.result) == null? sr : reducer.apply(tr, sr);
5700 >                                t.result = ((tr = t.result) == null) ? sr : reducer.apply(tr, sr);
5701                          }
5702                          if ((par = t.parent) == null ||
5703                              !(par instanceof ReduceEntriesTask)) {
# Line 5634 | Line 5712 | public class ConcurrentHashMapV8<K, V>
5712              } catch (Throwable ex) {
5713                  return tryCompleteComputation(ex);
5714              }
5715 +            for (ReduceEntriesTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
5716 +                s.exec();
5717              return false;
5718          }
5719          public final Map.Entry<K,V> getRawResult() { return result; }
# Line 5646 | Line 5726 | public class ConcurrentHashMapV8<K, V>
5726          U result;
5727          MapReduceKeysTask<K,V,U> rights, nextRight;
5728          MapReduceKeysTask
5729 <            (ConcurrentHashMapV8<K,V> m,
5650 <             Fun<? super K, ? extends U> transformer,
5651 <             BiFun<? super U, ? super U, ? extends U> reducer) {
5652 <            super(m);
5653 <            this.transformer = transformer;
5654 <            this.reducer = reducer;
5655 <        }
5656 <        MapReduceKeysTask
5657 <            (BulkTask<K,V,?> p, int b,
5729 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5730               MapReduceKeysTask<K,V,U> nextRight,
5731               Fun<? super K, ? extends U> transformer,
5732               BiFun<? super U, ? super U, ? extends U> reducer) {
5733 <            super(p, b); this.nextRight = nextRight;
5733 >            super(m, p, b); this.nextRight = nextRight;
5734              this.transformer = transformer;
5735              this.reducer = reducer;
5736          }
# Line 5673 | Line 5745 | public class ConcurrentHashMapV8<K, V>
5745                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5746                      do {} while (!casPending(c = pending, c+1));
5747                      (rights = new MapReduceKeysTask<K,V,U>
5748 <                     (this, b >>>= 1, rights, transformer, reducer)).fork();
5748 >                     (map, this, b >>>= 1, rights, transformer, reducer)).fork();
5749                  }
5750                  U r = null, u;
5751                  while (advance() != null) {
# Line 5686 | Line 5758 | public class ConcurrentHashMapV8<K, V>
5758                      if ((c = t.pending) == 0) {
5759                          for (s = t.rights; s != null; s = t.rights = s.nextRight) {
5760                              if ((sr = s.result) != null)
5761 <                                t.result = (tr = t.result) == null? sr : reducer.apply(tr, sr);
5761 >                                t.result = ((tr = t.result) == null) ? sr : reducer.apply(tr, sr);
5762                          }
5763                          if ((par = t.parent) == null ||
5764                              !(par instanceof MapReduceKeysTask)) {
# Line 5701 | Line 5773 | public class ConcurrentHashMapV8<K, V>
5773              } catch (Throwable ex) {
5774                  return tryCompleteComputation(ex);
5775              }
5776 +            for (MapReduceKeysTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
5777 +                s.exec();
5778              return false;
5779          }
5780          public final U getRawResult() { return result; }
# Line 5713 | Line 5787 | public class ConcurrentHashMapV8<K, V>
5787          U result;
5788          MapReduceValuesTask<K,V,U> rights, nextRight;
5789          MapReduceValuesTask
5790 <            (ConcurrentHashMapV8<K,V> m,
5717 <             Fun<? super V, ? extends U> transformer,
5718 <             BiFun<? super U, ? super U, ? extends U> reducer) {
5719 <            super(m);
5720 <            this.transformer = transformer;
5721 <            this.reducer = reducer;
5722 <        }
5723 <        MapReduceValuesTask
5724 <            (BulkTask<K,V,?> p, int b,
5790 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5791               MapReduceValuesTask<K,V,U> nextRight,
5792               Fun<? super V, ? extends U> transformer,
5793               BiFun<? super U, ? super U, ? extends U> reducer) {
5794 <            super(p, b); this.nextRight = nextRight;
5794 >            super(m, p, b); this.nextRight = nextRight;
5795              this.transformer = transformer;
5796              this.reducer = reducer;
5797          }
# Line 5740 | Line 5806 | public class ConcurrentHashMapV8<K, V>
5806                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5807                      do {} while (!casPending(c = pending, c+1));
5808                      (rights = new MapReduceValuesTask<K,V,U>
5809 <                     (this, b >>>= 1, rights, transformer, reducer)).fork();
5809 >                     (map, this, b >>>= 1, rights, transformer, reducer)).fork();
5810                  }
5811                  U r = null, u;
5812                  Object v;
# Line 5754 | Line 5820 | public class ConcurrentHashMapV8<K, V>
5820                      if ((c = t.pending) == 0) {
5821                          for (s = t.rights; s != null; s = t.rights = s.nextRight) {
5822                              if ((sr = s.result) != null)
5823 <                                t.result = (tr = t.result) == null? sr : reducer.apply(tr, sr);
5823 >                                t.result = ((tr = t.result) == null) ? sr : reducer.apply(tr, sr);
5824                          }
5825                          if ((par = t.parent) == null ||
5826                              !(par instanceof MapReduceValuesTask)) {
# Line 5769 | Line 5835 | public class ConcurrentHashMapV8<K, V>
5835              } catch (Throwable ex) {
5836                  return tryCompleteComputation(ex);
5837              }
5838 +            for (MapReduceValuesTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
5839 +                s.exec();
5840              return false;
5841          }
5842          public final U getRawResult() { return result; }
# Line 5781 | Line 5849 | public class ConcurrentHashMapV8<K, V>
5849          U result;
5850          MapReduceEntriesTask<K,V,U> rights, nextRight;
5851          MapReduceEntriesTask
5852 <            (ConcurrentHashMapV8<K,V> m,
5785 <             Fun<Map.Entry<K,V>, ? extends U> transformer,
5786 <             BiFun<? super U, ? super U, ? extends U> reducer) {
5787 <            super(m);
5788 <            this.transformer = transformer;
5789 <            this.reducer = reducer;
5790 <        }
5791 <        MapReduceEntriesTask
5792 <            (BulkTask<K,V,?> p, int b,
5852 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5853               MapReduceEntriesTask<K,V,U> nextRight,
5854               Fun<Map.Entry<K,V>, ? extends U> transformer,
5855               BiFun<? super U, ? super U, ? extends U> reducer) {
5856 <            super(p, b); this.nextRight = nextRight;
5856 >            super(m, p, b); this.nextRight = nextRight;
5857              this.transformer = transformer;
5858              this.reducer = reducer;
5859          }
# Line 5808 | Line 5868 | public class ConcurrentHashMapV8<K, V>
5868                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5869                      do {} while (!casPending(c = pending, c+1));
5870                      (rights = new MapReduceEntriesTask<K,V,U>
5871 <                     (this, b >>>= 1, rights, transformer, reducer)).fork();
5871 >                     (map, this, b >>>= 1, rights, transformer, reducer)).fork();
5872                  }
5873                  U r = null, u;
5874                  Object v;
# Line 5822 | Line 5882 | public class ConcurrentHashMapV8<K, V>
5882                      if ((c = t.pending) == 0) {
5883                          for (s = t.rights; s != null; s = t.rights = s.nextRight) {
5884                              if ((sr = s.result) != null)
5885 <                                t.result = (tr = t.result) == null? sr : reducer.apply(tr, sr);
5885 >                                t.result = ((tr = t.result) == null) ? sr : reducer.apply(tr, sr);
5886                          }
5887                          if ((par = t.parent) == null ||
5888                              !(par instanceof MapReduceEntriesTask)) {
# Line 5837 | Line 5897 | public class ConcurrentHashMapV8<K, V>
5897              } catch (Throwable ex) {
5898                  return tryCompleteComputation(ex);
5899              }
5900 +            for (MapReduceEntriesTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
5901 +                s.exec();
5902              return false;
5903          }
5904          public final U getRawResult() { return result; }
# Line 5849 | Line 5911 | public class ConcurrentHashMapV8<K, V>
5911          U result;
5912          MapReduceMappingsTask<K,V,U> rights, nextRight;
5913          MapReduceMappingsTask
5914 <            (ConcurrentHashMapV8<K,V> m,
5853 <             BiFun<? super K, ? super V, ? extends U> transformer,
5854 <             BiFun<? super U, ? super U, ? extends U> reducer) {
5855 <            super(m);
5856 <            this.transformer = transformer;
5857 <            this.reducer = reducer;
5858 <        }
5859 <        MapReduceMappingsTask
5860 <            (BulkTask<K,V,?> p, int b,
5914 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5915               MapReduceMappingsTask<K,V,U> nextRight,
5916               BiFun<? super K, ? super V, ? extends U> transformer,
5917               BiFun<? super U, ? super U, ? extends U> reducer) {
5918 <            super(p, b); this.nextRight = nextRight;
5918 >            super(m, p, b); this.nextRight = nextRight;
5919              this.transformer = transformer;
5920              this.reducer = reducer;
5921          }
# Line 5876 | Line 5930 | public class ConcurrentHashMapV8<K, V>
5930                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5931                      do {} while (!casPending(c = pending, c+1));
5932                      (rights = new MapReduceMappingsTask<K,V,U>
5933 <                     (this, b >>>= 1, rights, transformer, reducer)).fork();
5933 >                     (map, this, b >>>= 1, rights, transformer, reducer)).fork();
5934                  }
5935                  U r = null, u;
5936                  Object v;
# Line 5890 | Line 5944 | public class ConcurrentHashMapV8<K, V>
5944                      if ((c = t.pending) == 0) {
5945                          for (s = t.rights; s != null; s = t.rights = s.nextRight) {
5946                              if ((sr = s.result) != null)
5947 <                                t.result = (tr = t.result) == null? sr : reducer.apply(tr, sr);
5947 >                                t.result = ((tr = t.result) == null) ? sr : reducer.apply(tr, sr);
5948                          }
5949                          if ((par = t.parent) == null ||
5950                              !(par instanceof MapReduceMappingsTask)) {
# Line 5905 | Line 5959 | public class ConcurrentHashMapV8<K, V>
5959              } catch (Throwable ex) {
5960                  return tryCompleteComputation(ex);
5961              }
5962 +            for (MapReduceMappingsTask<K,V,U> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
5963 +                s.exec();
5964              return false;
5965          }
5966          public final U getRawResult() { return result; }
# Line 5918 | Line 5974 | public class ConcurrentHashMapV8<K, V>
5974          double result;
5975          MapReduceKeysToDoubleTask<K,V> rights, nextRight;
5976          MapReduceKeysToDoubleTask
5977 <            (ConcurrentHashMapV8<K,V> m,
5922 <             ObjectToDouble<? super K> transformer,
5923 <             double basis,
5924 <             DoubleByDoubleToDouble reducer) {
5925 <            super(m);
5926 <            this.transformer = transformer;
5927 <            this.basis = basis; this.reducer = reducer;
5928 <        }
5929 <        MapReduceKeysToDoubleTask
5930 <            (BulkTask<K,V,?> p, int b,
5977 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
5978               MapReduceKeysToDoubleTask<K,V> nextRight,
5979               ObjectToDouble<? super K> transformer,
5980               double basis,
5981               DoubleByDoubleToDouble reducer) {
5982 <            super(p, b); this.nextRight = nextRight;
5982 >            super(m, p, b); this.nextRight = nextRight;
5983              this.transformer = transformer;
5984              this.basis = basis; this.reducer = reducer;
5985          }
# Line 5947 | Line 5994 | public class ConcurrentHashMapV8<K, V>
5994                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
5995                      do {} while (!casPending(c = pending, c+1));
5996                      (rights = new MapReduceKeysToDoubleTask<K,V>
5997 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
5997 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
5998                  }
5999                  double r = id;
6000                  while (advance() != null)
# Line 5972 | Line 6019 | public class ConcurrentHashMapV8<K, V>
6019              } catch (Throwable ex) {
6020                  return tryCompleteComputation(ex);
6021              }
6022 +            for (MapReduceKeysToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6023 +                s.exec();
6024              return false;
6025          }
6026          public final Double getRawResult() { return result; }
# Line 5985 | Line 6034 | public class ConcurrentHashMapV8<K, V>
6034          double result;
6035          MapReduceValuesToDoubleTask<K,V> rights, nextRight;
6036          MapReduceValuesToDoubleTask
6037 <            (ConcurrentHashMapV8<K,V> m,
5989 <             ObjectToDouble<? super V> transformer,
5990 <             double basis,
5991 <             DoubleByDoubleToDouble reducer) {
5992 <            super(m);
5993 <            this.transformer = transformer;
5994 <            this.basis = basis; this.reducer = reducer;
5995 <        }
5996 <        MapReduceValuesToDoubleTask
5997 <            (BulkTask<K,V,?> p, int b,
6037 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6038               MapReduceValuesToDoubleTask<K,V> nextRight,
6039               ObjectToDouble<? super V> transformer,
6040               double basis,
6041               DoubleByDoubleToDouble reducer) {
6042 <            super(p, b); this.nextRight = nextRight;
6042 >            super(m, p, b); this.nextRight = nextRight;
6043              this.transformer = transformer;
6044              this.basis = basis; this.reducer = reducer;
6045          }
# Line 6014 | Line 6054 | public class ConcurrentHashMapV8<K, V>
6054                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6055                      do {} while (!casPending(c = pending, c+1));
6056                      (rights = new MapReduceValuesToDoubleTask<K,V>
6057 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6057 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6058                  }
6059                  double r = id;
6060                  Object v;
# Line 6040 | Line 6080 | public class ConcurrentHashMapV8<K, V>
6080              } catch (Throwable ex) {
6081                  return tryCompleteComputation(ex);
6082              }
6083 +            for (MapReduceValuesToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6084 +                s.exec();
6085              return false;
6086          }
6087          public final Double getRawResult() { return result; }
# Line 6053 | Line 6095 | public class ConcurrentHashMapV8<K, V>
6095          double result;
6096          MapReduceEntriesToDoubleTask<K,V> rights, nextRight;
6097          MapReduceEntriesToDoubleTask
6098 <            (ConcurrentHashMapV8<K,V> m,
6057 <             ObjectToDouble<Map.Entry<K,V>> transformer,
6058 <             double basis,
6059 <             DoubleByDoubleToDouble reducer) {
6060 <            super(m);
6061 <            this.transformer = transformer;
6062 <            this.basis = basis; this.reducer = reducer;
6063 <        }
6064 <        MapReduceEntriesToDoubleTask
6065 <            (BulkTask<K,V,?> p, int b,
6098 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6099               MapReduceEntriesToDoubleTask<K,V> nextRight,
6100               ObjectToDouble<Map.Entry<K,V>> transformer,
6101               double basis,
6102               DoubleByDoubleToDouble reducer) {
6103 <            super(p, b); this.nextRight = nextRight;
6103 >            super(m, p, b); this.nextRight = nextRight;
6104              this.transformer = transformer;
6105              this.basis = basis; this.reducer = reducer;
6106          }
# Line 6082 | Line 6115 | public class ConcurrentHashMapV8<K, V>
6115                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6116                      do {} while (!casPending(c = pending, c+1));
6117                      (rights = new MapReduceEntriesToDoubleTask<K,V>
6118 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6118 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6119                  }
6120                  double r = id;
6121                  Object v;
# Line 6108 | Line 6141 | public class ConcurrentHashMapV8<K, V>
6141              } catch (Throwable ex) {
6142                  return tryCompleteComputation(ex);
6143              }
6144 +            for (MapReduceEntriesToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6145 +                s.exec();
6146              return false;
6147          }
6148          public final Double getRawResult() { return result; }
# Line 6121 | Line 6156 | public class ConcurrentHashMapV8<K, V>
6156          double result;
6157          MapReduceMappingsToDoubleTask<K,V> rights, nextRight;
6158          MapReduceMappingsToDoubleTask
6159 <            (ConcurrentHashMapV8<K,V> m,
6125 <             ObjectByObjectToDouble<? super K, ? super V> transformer,
6126 <             double basis,
6127 <             DoubleByDoubleToDouble reducer) {
6128 <            super(m);
6129 <            this.transformer = transformer;
6130 <            this.basis = basis; this.reducer = reducer;
6131 <        }
6132 <        MapReduceMappingsToDoubleTask
6133 <            (BulkTask<K,V,?> p, int b,
6159 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6160               MapReduceMappingsToDoubleTask<K,V> nextRight,
6161               ObjectByObjectToDouble<? super K, ? super V> transformer,
6162               double basis,
6163               DoubleByDoubleToDouble reducer) {
6164 <            super(p, b); this.nextRight = nextRight;
6164 >            super(m, p, b); this.nextRight = nextRight;
6165              this.transformer = transformer;
6166              this.basis = basis; this.reducer = reducer;
6167          }
# Line 6150 | Line 6176 | public class ConcurrentHashMapV8<K, V>
6176                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6177                      do {} while (!casPending(c = pending, c+1));
6178                      (rights = new MapReduceMappingsToDoubleTask<K,V>
6179 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6179 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6180                  }
6181                  double r = id;
6182                  Object v;
# Line 6176 | Line 6202 | public class ConcurrentHashMapV8<K, V>
6202              } catch (Throwable ex) {
6203                  return tryCompleteComputation(ex);
6204              }
6205 +            for (MapReduceMappingsToDoubleTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6206 +                s.exec();
6207              return false;
6208          }
6209          public final Double getRawResult() { return result; }
# Line 6189 | Line 6217 | public class ConcurrentHashMapV8<K, V>
6217          long result;
6218          MapReduceKeysToLongTask<K,V> rights, nextRight;
6219          MapReduceKeysToLongTask
6220 <            (ConcurrentHashMapV8<K,V> m,
6193 <             ObjectToLong<? super K> transformer,
6194 <             long basis,
6195 <             LongByLongToLong reducer) {
6196 <            super(m);
6197 <            this.transformer = transformer;
6198 <            this.basis = basis; this.reducer = reducer;
6199 <        }
6200 <        MapReduceKeysToLongTask
6201 <            (BulkTask<K,V,?> p, int b,
6220 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6221               MapReduceKeysToLongTask<K,V> nextRight,
6222               ObjectToLong<? super K> transformer,
6223               long basis,
6224               LongByLongToLong reducer) {
6225 <            super(p, b); this.nextRight = nextRight;
6225 >            super(m, p, b); this.nextRight = nextRight;
6226              this.transformer = transformer;
6227              this.basis = basis; this.reducer = reducer;
6228          }
# Line 6218 | Line 6237 | public class ConcurrentHashMapV8<K, V>
6237                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6238                      do {} while (!casPending(c = pending, c+1));
6239                      (rights = new MapReduceKeysToLongTask<K,V>
6240 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6240 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6241                  }
6242                  long r = id;
6243                  while (advance() != null)
# Line 6243 | Line 6262 | public class ConcurrentHashMapV8<K, V>
6262              } catch (Throwable ex) {
6263                  return tryCompleteComputation(ex);
6264              }
6265 +            for (MapReduceKeysToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6266 +                s.exec();
6267              return false;
6268          }
6269          public final Long getRawResult() { return result; }
# Line 6256 | Line 6277 | public class ConcurrentHashMapV8<K, V>
6277          long result;
6278          MapReduceValuesToLongTask<K,V> rights, nextRight;
6279          MapReduceValuesToLongTask
6280 <            (ConcurrentHashMapV8<K,V> m,
6260 <             ObjectToLong<? super V> transformer,
6261 <             long basis,
6262 <             LongByLongToLong reducer) {
6263 <            super(m);
6264 <            this.transformer = transformer;
6265 <            this.basis = basis; this.reducer = reducer;
6266 <        }
6267 <        MapReduceValuesToLongTask
6268 <            (BulkTask<K,V,?> p, int b,
6280 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6281               MapReduceValuesToLongTask<K,V> nextRight,
6282               ObjectToLong<? super V> transformer,
6283               long basis,
6284               LongByLongToLong reducer) {
6285 <            super(p, b); this.nextRight = nextRight;
6285 >            super(m, p, b); this.nextRight = nextRight;
6286              this.transformer = transformer;
6287              this.basis = basis; this.reducer = reducer;
6288          }
# Line 6285 | Line 6297 | public class ConcurrentHashMapV8<K, V>
6297                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6298                      do {} while (!casPending(c = pending, c+1));
6299                      (rights = new MapReduceValuesToLongTask<K,V>
6300 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6300 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6301                  }
6302                  long r = id;
6303                  Object v;
# Line 6311 | Line 6323 | public class ConcurrentHashMapV8<K, V>
6323              } catch (Throwable ex) {
6324                  return tryCompleteComputation(ex);
6325              }
6326 +            for (MapReduceValuesToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6327 +                s.exec();
6328              return false;
6329          }
6330          public final Long getRawResult() { return result; }
# Line 6324 | Line 6338 | public class ConcurrentHashMapV8<K, V>
6338          long result;
6339          MapReduceEntriesToLongTask<K,V> rights, nextRight;
6340          MapReduceEntriesToLongTask
6341 <            (ConcurrentHashMapV8<K,V> m,
6328 <             ObjectToLong<Map.Entry<K,V>> transformer,
6329 <             long basis,
6330 <             LongByLongToLong reducer) {
6331 <            super(m);
6332 <            this.transformer = transformer;
6333 <            this.basis = basis; this.reducer = reducer;
6334 <        }
6335 <        MapReduceEntriesToLongTask
6336 <            (BulkTask<K,V,?> p, int b,
6341 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6342               MapReduceEntriesToLongTask<K,V> nextRight,
6343               ObjectToLong<Map.Entry<K,V>> transformer,
6344               long basis,
6345               LongByLongToLong reducer) {
6346 <            super(p, b); this.nextRight = nextRight;
6346 >            super(m, p, b); this.nextRight = nextRight;
6347              this.transformer = transformer;
6348              this.basis = basis; this.reducer = reducer;
6349          }
# Line 6353 | Line 6358 | public class ConcurrentHashMapV8<K, V>
6358                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6359                      do {} while (!casPending(c = pending, c+1));
6360                      (rights = new MapReduceEntriesToLongTask<K,V>
6361 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6361 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6362                  }
6363                  long r = id;
6364                  Object v;
# Line 6379 | Line 6384 | public class ConcurrentHashMapV8<K, V>
6384              } catch (Throwable ex) {
6385                  return tryCompleteComputation(ex);
6386              }
6387 +            for (MapReduceEntriesToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6388 +                s.exec();
6389              return false;
6390          }
6391          public final Long getRawResult() { return result; }
# Line 6392 | Line 6399 | public class ConcurrentHashMapV8<K, V>
6399          long result;
6400          MapReduceMappingsToLongTask<K,V> rights, nextRight;
6401          MapReduceMappingsToLongTask
6402 <            (ConcurrentHashMapV8<K,V> m,
6396 <             ObjectByObjectToLong<? super K, ? super V> transformer,
6397 <             long basis,
6398 <             LongByLongToLong reducer) {
6399 <            super(m);
6400 <            this.transformer = transformer;
6401 <            this.basis = basis; this.reducer = reducer;
6402 <        }
6403 <        MapReduceMappingsToLongTask
6404 <            (BulkTask<K,V,?> p, int b,
6402 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6403               MapReduceMappingsToLongTask<K,V> nextRight,
6404               ObjectByObjectToLong<? super K, ? super V> transformer,
6405               long basis,
6406               LongByLongToLong reducer) {
6407 <            super(p, b); this.nextRight = nextRight;
6407 >            super(m, p, b); this.nextRight = nextRight;
6408              this.transformer = transformer;
6409              this.basis = basis; this.reducer = reducer;
6410          }
# Line 6421 | Line 6419 | public class ConcurrentHashMapV8<K, V>
6419                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6420                      do {} while (!casPending(c = pending, c+1));
6421                      (rights = new MapReduceMappingsToLongTask<K,V>
6422 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6422 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6423                  }
6424                  long r = id;
6425                  Object v;
# Line 6447 | Line 6445 | public class ConcurrentHashMapV8<K, V>
6445              } catch (Throwable ex) {
6446                  return tryCompleteComputation(ex);
6447              }
6448 +            for (MapReduceMappingsToLongTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6449 +                s.exec();
6450              return false;
6451          }
6452          public final Long getRawResult() { return result; }
# Line 6460 | Line 6460 | public class ConcurrentHashMapV8<K, V>
6460          int result;
6461          MapReduceKeysToIntTask<K,V> rights, nextRight;
6462          MapReduceKeysToIntTask
6463 <            (ConcurrentHashMapV8<K,V> m,
6464 <             ObjectToInt<? super K> transformer,
6465 <             int basis,
6466 <             IntByIntToInt reducer) {
6467 <            super(m);
6468 <            this.transformer = transformer;
6469 <            this.basis = basis; this.reducer = reducer;
6470 <        }
6471 <        MapReduceKeysToIntTask
6472 <            (BulkTask<K,V,?> p, int b,
6463 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6464               MapReduceKeysToIntTask<K,V> nextRight,
6465               ObjectToInt<? super K> transformer,
6466               int basis,
6467               IntByIntToInt reducer) {
6468 <            super(p, b); this.nextRight = nextRight;
6468 >            super(m, p, b); this.nextRight = nextRight;
6469              this.transformer = transformer;
6470              this.basis = basis; this.reducer = reducer;
6471          }
# Line 6489 | Line 6480 | public class ConcurrentHashMapV8<K, V>
6480                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6481                      do {} while (!casPending(c = pending, c+1));
6482                      (rights = new MapReduceKeysToIntTask<K,V>
6483 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6483 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6484                  }
6485                  int r = id;
6486                  while (advance() != null)
# Line 6514 | Line 6505 | public class ConcurrentHashMapV8<K, V>
6505              } catch (Throwable ex) {
6506                  return tryCompleteComputation(ex);
6507              }
6508 +            for (MapReduceKeysToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6509 +                s.exec();
6510              return false;
6511          }
6512          public final Integer getRawResult() { return result; }
# Line 6527 | Line 6520 | public class ConcurrentHashMapV8<K, V>
6520          int result;
6521          MapReduceValuesToIntTask<K,V> rights, nextRight;
6522          MapReduceValuesToIntTask
6523 <            (ConcurrentHashMapV8<K,V> m,
6531 <             ObjectToInt<? super V> transformer,
6532 <             int basis,
6533 <             IntByIntToInt reducer) {
6534 <            super(m);
6535 <            this.transformer = transformer;
6536 <            this.basis = basis; this.reducer = reducer;
6537 <        }
6538 <        MapReduceValuesToIntTask
6539 <            (BulkTask<K,V,?> p, int b,
6523 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6524               MapReduceValuesToIntTask<K,V> nextRight,
6525               ObjectToInt<? super V> transformer,
6526               int basis,
6527               IntByIntToInt reducer) {
6528 <            super(p, b); this.nextRight = nextRight;
6528 >            super(m, p, b); this.nextRight = nextRight;
6529              this.transformer = transformer;
6530              this.basis = basis; this.reducer = reducer;
6531          }
# Line 6556 | Line 6540 | public class ConcurrentHashMapV8<K, V>
6540                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6541                      do {} while (!casPending(c = pending, c+1));
6542                      (rights = new MapReduceValuesToIntTask<K,V>
6543 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6543 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6544                  }
6545                  int r = id;
6546                  Object v;
# Line 6582 | Line 6566 | public class ConcurrentHashMapV8<K, V>
6566              } catch (Throwable ex) {
6567                  return tryCompleteComputation(ex);
6568              }
6569 +            for (MapReduceValuesToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6570 +                s.exec();
6571              return false;
6572          }
6573          public final Integer getRawResult() { return result; }
# Line 6595 | Line 6581 | public class ConcurrentHashMapV8<K, V>
6581          int result;
6582          MapReduceEntriesToIntTask<K,V> rights, nextRight;
6583          MapReduceEntriesToIntTask
6584 <            (ConcurrentHashMapV8<K,V> m,
6599 <             ObjectToInt<Map.Entry<K,V>> transformer,
6600 <             int basis,
6601 <             IntByIntToInt reducer) {
6602 <            super(m);
6603 <            this.transformer = transformer;
6604 <            this.basis = basis; this.reducer = reducer;
6605 <        }
6606 <        MapReduceEntriesToIntTask
6607 <            (BulkTask<K,V,?> p, int b,
6584 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6585               MapReduceEntriesToIntTask<K,V> nextRight,
6586               ObjectToInt<Map.Entry<K,V>> transformer,
6587               int basis,
6588               IntByIntToInt reducer) {
6589 <            super(p, b); this.nextRight = nextRight;
6589 >            super(m, p, b); this.nextRight = nextRight;
6590              this.transformer = transformer;
6591              this.basis = basis; this.reducer = reducer;
6592          }
# Line 6624 | Line 6601 | public class ConcurrentHashMapV8<K, V>
6601                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6602                      do {} while (!casPending(c = pending, c+1));
6603                      (rights = new MapReduceEntriesToIntTask<K,V>
6604 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6604 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6605                  }
6606                  int r = id;
6607                  Object v;
# Line 6650 | Line 6627 | public class ConcurrentHashMapV8<K, V>
6627              } catch (Throwable ex) {
6628                  return tryCompleteComputation(ex);
6629              }
6630 +            for (MapReduceEntriesToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6631 +                s.exec();
6632              return false;
6633          }
6634          public final Integer getRawResult() { return result; }
# Line 6663 | Line 6642 | public class ConcurrentHashMapV8<K, V>
6642          int result;
6643          MapReduceMappingsToIntTask<K,V> rights, nextRight;
6644          MapReduceMappingsToIntTask
6645 <            (ConcurrentHashMapV8<K,V> m,
6646 <             ObjectByObjectToInt<? super K, ? super V> transformer,
6668 <             int basis,
6669 <             IntByIntToInt reducer) {
6670 <            super(m);
6671 <            this.transformer = transformer;
6672 <            this.basis = basis; this.reducer = reducer;
6673 <        }
6674 <        MapReduceMappingsToIntTask
6675 <            (BulkTask<K,V,?> p, int b,
6676 <             MapReduceMappingsToIntTask<K,V> nextRight,
6645 >            (ConcurrentHashMapV8<K,V> m, BulkTask<K,V,?> p, int b,
6646 >             MapReduceMappingsToIntTask<K,V> rights,
6647               ObjectByObjectToInt<? super K, ? super V> transformer,
6648               int basis,
6649               IntByIntToInt reducer) {
6650 <            super(p, b); this.nextRight = nextRight;
6650 >            super(m, p, b); this.nextRight = nextRight;
6651              this.transformer = transformer;
6652              this.basis = basis; this.reducer = reducer;
6653          }
# Line 6692 | Line 6662 | public class ConcurrentHashMapV8<K, V>
6662                  for (int c, b = batch(); b > 1 && baseIndex != baseLimit;) {
6663                      do {} while (!casPending(c = pending, c+1));
6664                      (rights = new MapReduceMappingsToIntTask<K,V>
6665 <                     (this, b >>>= 1, rights, transformer, id, reducer)).fork();
6665 >                     (map, this, b >>>= 1, rights, transformer, id, reducer)).fork();
6666                  }
6667                  int r = id;
6668                  Object v;
# Line 6718 | Line 6688 | public class ConcurrentHashMapV8<K, V>
6688              } catch (Throwable ex) {
6689                  return tryCompleteComputation(ex);
6690              }
6691 +            for (MapReduceMappingsToIntTask<K,V> s = rights; s != null && s.tryUnfork(); s = s.nextRight)
6692 +                s.exec();
6693              return false;
6694          }
6695          public final Integer getRawResult() { return result; }
6696      }
6697  
6726
6698      // Unsafe mechanics
6699      private static final sun.misc.Unsafe UNSAFE;
6700      private static final long counterOffset;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines