--- jsr166/src/jsr166y/RecursiveAction.java 2009/08/04 14:42:02 1.11 +++ jsr166/src/jsr166y/RecursiveAction.java 2011/03/15 19:47:02 1.16 @@ -1,7 +1,7 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ package jsr166y; @@ -64,7 +64,7 @@ package jsr166y; * of each element of a double array, by subdividing out only the * right-hand-sides of repeated divisions by two, and keeping track of * them with a chain of {@code next} references. It uses a dynamic - * threshold based on method {@code getEstimatedSurplusTaskCount}, but + * threshold based on method {@code getSurplusQueuedTaskCount}, but * counterbalances potential excess partitioning by directly * performing leaf actions on unstolen tasks rather than further * subdividing. @@ -72,23 +72,22 @@ package jsr166y; *
{@code * double sumOfSquares(ForkJoinPool pool, double[] array) { * int n = array.length; - * int seqSize = 1 + n / (8 * pool.getParallelism()); - * Applyer a = new Applyer(array, 0, n, seqSize, null); + * Applyer a = new Applyer(array, 0, n, null); * pool.invoke(a); * return a.result; * } * * class Applyer extends RecursiveAction { * final double[] array; - * final int lo, hi, seqSize; + * final int lo, hi; * double result; * Applyer next; // keeps track of right-hand-side tasks - * Applyer(double[] array, int lo, int hi, int seqSize, Applyer next) { + * Applyer(double[] array, int lo, int hi, Applyer next) { * this.array = array; this.lo = lo; this.hi = hi; - * this.seqSize = seqSize; this.next = next; + * this.next = next; * } * - * double atLeaf(int l, int r) { + * double atLeaf(int l, int h) { * double sum = 0; * for (int i = l; i < h; ++i) // perform leftmost base step * sum += array[i] * array[i]; @@ -101,7 +100,7 @@ package jsr166y; * Applyer right = null; * while (h - l > 1 && getSurplusQueuedTaskCount() <= 3) { * int mid = (l + h) >>> 1; - * right = new Applyer(array, mid, h, seqSize, right); + * right = new Applyer(array, mid, h, right); * right.fork(); * h = mid; * } @@ -110,7 +109,7 @@ package jsr166y; * if (right.tryUnfork()) // directly calculate if not stolen * sum += right.atLeaf(right.lo, right.hi); * else { - * right.helpJoin(); + * right.join(); * sum += right.result; * } * right = right.next; @@ -131,7 +130,9 @@ public abstract class RecursiveAction ex protected abstract void compute(); /** - * Always returns null. + * Always returns {@code null}. + * + * @return {@code null} always */ public final Void getRawResult() { return null; }