--- jsr166/src/jsr166y/RecursiveAction.java 2009/07/22 01:36:51 1.6 +++ jsr166/src/jsr166y/RecursiveAction.java 2010/09/18 19:53:08 1.14 @@ -7,11 +7,11 @@ package jsr166y; /** - * Recursive resultless ForkJoinTasks. This class establishes - * conventions to parameterize resultless actions as {@code Void} - * ForkJoinTasks. Because {@code null} is the only valid value of - * type {@code Void}, methods such as join always return {@code null} - * upon completion. + * A recursive resultless {@link ForkJoinTask}. This class + * establishes conventions to parameterize resultless actions as + * {@code Void} {@code ForkJoinTask}s. Because {@code null} is the + * only valid value of type {@code Void}, methods such as join always + * return {@code null} upon completion. * *

Sample Usages. Here is a sketch of a ForkJoin sort that * sorts a given {@code long[]} array: @@ -34,10 +34,10 @@ package jsr166y; * } * }} * - * You could then sort anArray by creating {@code new SortTask(anArray, 0, - * anArray.length-1) } and invoking it in a ForkJoinPool. - * As a more concrete simple example, the following task increments - * each element of an array: + * You could then sort {@code anArray} by creating {@code new + * SortTask(anArray, 0, anArray.length-1) } and invoking it in a + * ForkJoinPool. As a more concrete simple example, the following + * task increments each element of an array: *

 {@code
  * class IncrementTask extends RecursiveAction {
  *   final long[] array; final int lo; final int hi;
@@ -64,30 +64,30 @@ 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 surplus}, but counterbalances
- * potential excess partitioning by directly performing leaf actions
- * on unstolen tasks rather than further subdividing.
+ * threshold based on method {@code getSurplusQueuedTaskCount}, but
+ * counterbalances potential excess partitioning by directly
+ * performing leaf actions on unstolen tasks rather than further
+ * subdividing.
  *
  *  
 {@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];
@@ -98,10 +98,9 @@ package jsr166y;
  *     int l = lo;
  *     int h = hi;
  *     Applyer right = null;
- *     while (h - l > 1 &&
- *        ForkJoinWorkerThread.getEstimatedSurplusTaskCount() <= 3) {
+ *     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;
@@ -123,6 +122,7 @@ package jsr166y;
  * @author Doug Lea
  */
 public abstract class RecursiveAction extends ForkJoinTask {
+    private static final long serialVersionUID = 5232453952276485070L;
 
     /**
      * The main computation performed by this task.