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.69 by jsr166, Sun Oct 21 06:14:11 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
# Line 2313 | 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
# Line 2347 | Line 2526 | public class ConcurrentHashMapV8<K, V>
2526          }
2527  
2528          public final void remove() {
2529 <            if (nextVal == null && last == null)
2530 <                advance();
2352 <            Node e = last;
2353 <            if (e == null)
2529 >            Object k = nextKey;
2530 >            if (k == null && (advance() == null || (k = nextKey) == null))
2531                  throw new IllegalStateException();
2532 <            last = null;
2356 <            map.remove(e.key);
2532 >            map.internalReplace(k, null, null);
2533          }
2534  
2535          public final boolean hasNext() {
# Line 2457 | 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 2475 | 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 2848 | 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
2852 <     * removal, which removes the corresponding mapping from this map,
2853 <     * via the {@code Iterator.remove}, {@code Set.remove},
2854 <     * {@code removeAll}, {@code retainAll}, and {@code clear}
2855 <     * operations.  It does not support the {@code add} or
2856 <     * {@code addAll} operations.
3053 >     * reflected in the set, and vice-versa.
3054       *
3055 <     * <p>The view's {@code iterator} is a "weakly consistent" iterator
3056 <     * that will never throw {@link ConcurrentModificationException},
3057 <     * and guarantees to traverse elements as they existed upon
3058 <     * construction of the iterator, and may (but is not guaranteed to)
3059 <     * reflect any modifications subsequent to construction.
3055 >     * @return the set view
3056 >     */
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 Set<K> keySet() {
3075 <        KeySet<K,V> ks = keySet;
3076 <        return (ks != null) ? ks : (keySet = new KeySet<K,V>(this));
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 3045 | 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 3067 | 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 3090 | 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 3278 | Line 3489 | public class ConcurrentHashMapV8<K, V>
3489  
3490      }
3491  
3281    static final class KeySet<K,V> extends CHMView<K,V> implements Set<K> {
3282        KeySet(ConcurrentHashMapV8<K, V> map)  {
3283            super(map);
3284        }
3285        public final boolean contains(Object o) { return map.containsKey(o); }
3286        public final boolean remove(Object o)   { return map.remove(o) != null; }
3287        public final Iterator<K> iterator() {
3288            return new KeyIterator<K,V>(map);
3289        }
3290        public final boolean add(K e) {
3291            throw new UnsupportedOperationException();
3292        }
3293        public final boolean addAll(Collection<? extends K> c) {
3294            throw new UnsupportedOperationException();
3295        }
3296        public boolean equals(Object o) {
3297            Set<?> c;
3298            return ((o instanceof Set) &&
3299                    ((c = (Set<?>)o) == this ||
3300                     (containsAll(c) && c.containsAll(this))));
3301        }
3302    }
3303
3304
3492      static final class Values<K,V> extends CHMView<K,V>
3493          implements Collection<V> {
3494          Values(ConcurrentHashMapV8<K, V> map)   { super(map); }
# Line 3531 | Line 3718 | public class ConcurrentHashMapV8<K, V>
3718      // -------------------------------------------------------
3719  
3720      /**
3721 <     * Returns an extended {@link Parallel} view of this map using the
3535 <     * given executor for bulk parallel operations.
3721 >     * Performs the given action for each (key, value).
3722       *
3723 <     * @param executor the executor
3538 <     * @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
3552 <     * (Key, Value) arguments and/or return values. Because the
3553 <     * elements of a ConcurrentHashMap are not ordered in any
3554 <     * particular way, and may be processed in different orders in
3555 <     * different parallel executions, the correctness of supplied
3556 <     * functions should not depend on any ordering, or on any other
3557 <     * objects or values that may transiently change while computation
3558 <     * is in progress; and except for forEach actions, should ideally
3559 <     * be side-effect-free.
3560 <     *
3561 <     * <ul>
3562 <     * <li> forEach: Perform a given action on each element.
3563 <     * A variant form applies a given transformation on each element
3564 <     * before performing the action.</li>
3565 <     *
3566 <     * <li> search: Return the first available non-null result of
3567 <     * applying a given function on each element; skipping further
3568 <     * search when a result is found.</li>
3569 <     *
3570 <     * <li> reduce: Accumulate each element.  The supplied reduction
3571 <     * function cannot rely on ordering (more formally, it should be
3572 <     * both associative and commutative).  There are five variants:
3573 <     *
3574 <     * <ul>
3575 <     *
3576 <     * <li> Plain reductions. (There is not a form of this method for
3577 <     * (key, value) function arguments since there is no corresponding
3578 <     * return type.)</li>
3579 <     *
3580 <     * <li> Mapped reductions that accumulate the results of a given
3581 <     * function applied to each element.</li>
3582 <     *
3583 <     * <li> Reductions to scalar doubles, longs, and ints, using a
3584 <     * given basis value.</li>
3585 <     *
3586 <     * </li>
3587 <     * </ul>
3588 <     * </ul>
3589 <     *
3590 <     * <p>The concurrency properties of the bulk operations follow
3591 <     * from those of ConcurrentHashMap: Any non-null result returned
3592 <     * from {@code get(key)} and related access methods bears a
3593 <     * happens-before relation with the associated insertion or
3594 <     * update.  The result of any bulk operation reflects the
3595 <     * composition of these per-element relations (but is not
3596 <     * necessarily atomic with respect to the map as a whole unless it
3597 <     * is somehow known to be quiescent).  Conversely, because keys
3598 <     * and values in the map are never null, null serves as a reliable
3599 <     * atomic indicator of the current lack of any result.  To
3600 <     * maintain this property, null serves as an implicit basis for
3601 <     * all non-scalar reduction operations. For the double, long, and
3602 <     * int versions, the basis should be one that, when combined with
3603 <     * any other value, returns that other value (more formally, it
3604 <     * should be the identity element for the reduction). Most common
3605 <     * reductions have these properties; for example, computing a sum
3606 <     * with basis 0 or a minimum with basis MAX_VALUE.
3607 <     *
3608 <     * <p>Search and transformation functions provided as arguments
3609 <     * should similarly return null to indicate the lack of any result
3610 <     * (in which case it is not used). In the case of mapped
3611 <     * reductions, this also enables transformations to serve as
3612 <     * filters, returning null (or, in the case of primitive
3613 <     * specializations, the identity basis) if the element should not
3614 <     * be combined. You can create compound transformations and
3615 <     * filterings by composing them yourself under this "null means
3616 <     * there is nothing there now" rule before using them in search or
3617 <     * reduce operations.
3618 <     *
3619 <     * <p>Methods accepting and/or returning Entry arguments maintain
3620 <     * key-value associations. They may be useful for example when
3621 <     * finding the key for the greatest value. Note that "plain" Entry
3622 <     * arguments can be supplied using {@code new
3623 <     * AbstractMap.SimpleEntry(k,v)}.
3624 <     *
3625 <     * <p> Bulk operations may complete abruptly, throwing an
3626 <     * exception encountered in the application of a supplied
3627 <     * function. Bear in mind when handling such exceptions that other
3628 <     * concurrently executing functions could also have thrown
3629 <     * exceptions, or would have done so if the first exception had
3630 <     * not occurred.
3631 <     *
3632 <     * <p>Parallel speedups compared to sequential processing are
3633 <     * common but not guaranteed.  Operations involving brief
3634 <     * functions on small maps may execute more slowly than sequential
3635 <     * loops if the underlying work to parallelize the computation is
3636 <     * more expensive than the computation itself. Similarly,
3637 <     * parallelization may not lead to much actual parallelism if all
3638 <     * processors are busy performing unrelated tasks.
3639 <     *
3640 <     * <p> All arguments to all task methods must be non-null.
3641 <     *
3642 <     * <p><em>jsr166e note: During transition, this class
3643 <     * uses nested functional interfaces with different names but the
3644 <     * 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 if 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 if 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 <        }
3775 <
3776 <        /**
3777 <         * Performs the given action for each key.
3778 <         *
3779 <         * @param action the action
3780 <         */
3781 <        public void forEachKey(Action<K> action) {
3782 <            fjp.invoke(ForkJoinTasks.forEachKey
3783 <                       (ConcurrentHashMapV8.this, action));
3784 <        }
3785 <
3786 <        /**
3787 <         * Performs the given action for each non-null transformation
3788 <         * of each key.
3789 <         *
3790 <         * @param transformer a function returning the transformation
3791 <         * for an element, or null if there is no transformation (in
3792 <         * which case the action is not applied)
3793 <         * @param action the action
3794 <         */
3795 <        public <U> void forEachKey(Fun<? super K, ? extends U> transformer,
3796 <                                   Action<U> action) {
3797 <            fjp.invoke(ForkJoinTasks.forEachKey
3798 <                       (ConcurrentHashMapV8.this, transformer, action));
3799 <        }
3800 <
3801 <        /**
3802 <         * Returns a non-null result from applying the given search
3803 <         * function on each key, or null if none. Upon success,
3804 <         * further element processing is suppressed and the results of
3805 <         * any other parallel invocations of the search function are
3806 <         * ignored.
3807 <         *
3808 <         * @param searchFunction a function returning a non-null
3809 <         * result on success, else null
3810 <         * @return a non-null result from applying the given search
3811 <         * function on each key, or null if none
3812 <         */
3813 <        public <U> U searchKeys(Fun<? super K, ? extends U> searchFunction) {
3814 <            return fjp.invoke(ForkJoinTasks.searchKeys
3815 <                              (ConcurrentHashMapV8.this, searchFunction));
3816 <        }
3817 <
3818 <        /**
3819 <         * Returns the result of accumulating all keys using the given
3820 <         * reducer to combine values, or null if none.
3821 <         *
3822 <         * @param reducer a commutative associative combining function
3823 <         * @return the result of accumulating all keys using the given
3824 <         * reducer to combine values, or null if none
3825 <         */
3826 <        public K reduceKeys(BiFun<? super K, ? super K, ? extends K> reducer) {
3827 <            return fjp.invoke(ForkJoinTasks.reduceKeys
3828 <                              (ConcurrentHashMapV8.this, reducer));
3829 <        }
3830 <
3831 <        /**
3832 <         * Returns the result of accumulating the given transformation
3833 <         * of all keys using the given reducer to combine values, or
3834 <         * null if none.
3835 <         *
3836 <         * @param transformer a function returning the transformation
3837 <         * for an element, or null if there is no transformation (in
3838 <         * which case it is not combined)
3839 <         * @param reducer a commutative associative combining function
3840 <         * @return the result of accumulating the given transformation
3841 <         * of all keys
3842 <         */
3843 <        public <U> U reduceKeys(Fun<? super K, ? extends U> transformer,
3844 <                                BiFun<? super U, ? super U, ? extends U> reducer) {
3845 <            return fjp.invoke(ForkJoinTasks.reduceKeys
3846 <                              (ConcurrentHashMapV8.this, transformer, reducer));
3847 <        }
3848 <
3849 <        /**
3850 <         * Returns the result of accumulating the given transformation
3851 <         * of all keys using the given reducer to combine values, and
3852 <         * the given basis as an identity value.
3853 <         *
3854 <         * @param transformer a function returning the transformation
3855 <         * for an element
3856 <         * @param basis the identity (initial default value) for the reduction
3857 <         * @param reducer a commutative associative combining function
3858 <         * @return  the result of accumulating the given transformation
3859 <         * of all keys
3860 <         */
3861 <        public double reduceKeysToDouble(ObjectToDouble<? super K> transformer,
3862 <                                         double basis,
3863 <                                         DoubleByDoubleToDouble reducer) {
3864 <            return fjp.invoke(ForkJoinTasks.reduceKeysToDouble
3865 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3866 <        }
3867 <
3868 <        /**
3869 <         * Returns the result of accumulating the given transformation
3870 <         * of all keys using the given reducer to combine values, and
3871 <         * the given basis as an identity value.
3872 <         *
3873 <         * @param transformer a function returning the transformation
3874 <         * for an element
3875 <         * @param basis the identity (initial default value) for the reduction
3876 <         * @param reducer a commutative associative combining function
3877 <         * @return the result of accumulating the given transformation
3878 <         * of all keys
3879 <         */
3880 <        public long reduceKeysToLong(ObjectToLong<? super K> transformer,
3881 <                                     long basis,
3882 <                                     LongByLongToLong reducer) {
3883 <            return fjp.invoke(ForkJoinTasks.reduceKeysToLong
3884 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3885 <        }
3886 <
3887 <        /**
3888 <         * Returns the result of accumulating the given transformation
3889 <         * of all keys using the given reducer to combine values, and
3890 <         * the given basis as an identity value.
3891 <         *
3892 <         * @param transformer a function returning the transformation
3893 <         * for an element
3894 <         * @param basis the identity (initial default value) for the reduction
3895 <         * @param reducer a commutative associative combining function
3896 <         * @return the result of accumulating the given transformation
3897 <         * of all keys
3898 <         */
3899 <        public int reduceKeysToInt(ObjectToInt<? super K> transformer,
3900 <                                   int basis,
3901 <                                   IntByIntToInt reducer) {
3902 <            return fjp.invoke(ForkJoinTasks.reduceKeysToInt
3903 <                              (ConcurrentHashMapV8.this, transformer, basis, reducer));
3904 <        }
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 if 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 <        public <U> U searchValues(Fun<? super V, ? extends U> searchFunction) {
3987 <            return fjp.invoke(ForkJoinTasks.searchValues
3988 <                              (ConcurrentHashMapV8.this, searchFunction));
3989 <        }
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 if 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 if 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 if 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));
4161 <        }
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 4186 | 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, null, -1, action);
4234 >            return new ForEachMappingTask<K,V>(map, null, -1, null, action);
4235          }
4236  
4237          /**
# Line 4207 | 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, null, -1, transformer, action);
4255 >                (map, null, -1, null, transformer, action);
4256          }
4257  
4258          /**
# Line 4227 | 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, null, -1, searchFunction,
4275 >                (map, null, -1, null, searchFunction,
4276                   new AtomicReference<U>());
4277          }
4278  
# Line 4336 | 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, null, -1, action);
4384 >            return new ForEachKeyTask<K,V>(map, null, -1, null, action);
4385          }
4386  
4387          /**
# Line 4357 | 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, null, -1, transformer, action);
4405 >                (map, null, -1, null, transformer, action);
4406          }
4407  
4408          /**
# Line 4377 | 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, null, -1, searchFunction,
4425 >                (map, null, -1, null, searchFunction,
4426                   new AtomicReference<U>());
4427          }
4428  
# Line 4503 | 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, null, -1, action);
4551 >            return new ForEachValueTask<K,V>(map, null, -1, null, action);
4552          }
4553  
4554          /**
# Line 4523 | 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, null, -1, transformer, action);
4571 >                (map, null, -1, null, transformer, action);
4572          }
4573  
4574          /**
# Line 4543 | Line 4588 | public class ConcurrentHashMapV8<K, V>
4588               Fun<? super V, ? extends U> searchFunction) {
4589              if (searchFunction == null) throw new NullPointerException();
4590              return new SearchValuesTask<K,V,U>
4591 <                (map, null, -1, searchFunction,
4591 >                (map, null, -1, null, searchFunction,
4592                   new AtomicReference<U>());
4593          }
4594  
# Line 4669 | 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, null, -1, action);
4717 >            return new ForEachEntryTask<K,V>(map, null, -1, null, action);
4718          }
4719  
4720          /**
# Line 4689 | 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, null, -1, transformer, action);
4737 >                (map, null, -1, null, transformer, action);
4738          }
4739  
4740          /**
# Line 4709 | Line 4754 | public class ConcurrentHashMapV8<K, V>
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, null, -1, searchFunction,
4757 >                (map, null, -1, null, searchFunction,
4758                   new AtomicReference<U>());
4759          }
4760  
# Line 4922 | Line 4967 | public class ConcurrentHashMapV8<K, V>
4967           * dividing by two anyway.
4968           */
4969          final int batch() {
4970 <            ConcurrentHashMapV8<K, V> m; int b; Node[] t;
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 sp = getPool().getParallelism() << 3; // slack of 8
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              }
# Line 4965 | 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, BulkTask<K,V,?> p, int b,
5019 +             ForEachKeyTask<K,V> nextRight,
5020               Action<K> action) {
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>(map, 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 4987 | 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, BulkTask<K,V,?> p, int b,
5057 +             ForEachValueTask<K,V> nextRight,
5058               Action<V> action) {
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>(map, 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 5017 | 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, BulkTask<K,V,?> p, int b,
5096 +             ForEachEntryTask<K,V> nextRight,
5097               Action<Entry<K,V>> action) {
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>(map, 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 5047 | 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, BulkTask<K,V,?> p, int b,
5135 +             ForEachMappingTask<K,V> nextRight,
5136               BiAction<K,V> action) {
5137              super(m, p, b);
5138 +            this.nextRight = nextRight;
5139              this.action = action;
5140          }
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>(map, 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 5078 | 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, 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, p, b);
5179 +            this.nextRight = nextRight;
5180              this.transformer = transformer;
5181              this.action = action;
5182  
# Line 5101 | Line 5187 | public class ConcurrentHashMapV8<K, V>
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 <                        (map, 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, 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, p, b);
5226 +            this.nextRight = nextRight;
5227              this.transformer = transformer;
5228              this.action = action;
5229  
# Line 5140 | Line 5234 | public class ConcurrentHashMapV8<K, V>
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 <                        (map, 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 5156 | 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, 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, p, b);
5273 +            this.nextRight = nextRight;
5274              this.transformer = transformer;
5275              this.action = action;
5276  
# Line 5179 | Line 5281 | public class ConcurrentHashMapV8<K, V>
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 <                        (map, 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 5195 | 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, 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, p, b);
5320 +            this.nextRight = nextRight;
5321              this.transformer = transformer;
5322              this.action = action;
5323  
# Line 5218 | Line 5328 | public class ConcurrentHashMapV8<K, V>
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 <                        (map, 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 5234 | 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, 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(m, p, b);
5367 +            this.nextRight = nextRight;
5368              this.searchFunction = searchFunction; this.result = result;
5369          }
5370          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5255 | 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>(map, 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 5274 | 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 5281 | 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, 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, p, b);
5416 +            this.nextRight = nextRight;
5417              this.searchFunction = searchFunction; this.result = result;
5418          }
5419          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5296 | 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>(map, 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 5315 | 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 5322 | 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, 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(m, p, b);
5465 +            this.nextRight = nextRight;
5466              this.searchFunction = searchFunction; this.result = result;
5467          }
5468          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5337 | 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>(map, 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 5356 | 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 5363 | 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, 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(m, p, b);
5514 +            this.nextRight = nextRight;
5515              this.searchFunction = searchFunction; this.result = result;
5516          }
5517          @SuppressWarnings("unchecked") public final boolean exec() {
# Line 5378 | 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>(map, 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 5397 | 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 5451 | 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 5506 | 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 5561 | 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 5620 | 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 5680 | 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 5740 | 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 5800 | 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 5858 | 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 5917 | 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 5976 | 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 6035 | 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 6093 | 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 6152 | 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 6211 | 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 6270 | 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 6328 | 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 6387 | 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 6446 | 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 6505 | 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  
6513
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