--- jsr166/src/test/loops/LinkedAsyncAction.java 2011/07/01 02:37:22 1.3 +++ jsr166/src/test/loops/LinkedAsyncAction.java 2012/11/26 05:46:55 1.8 @@ -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/publicdomain/zero/1.0/ */ import java.util.*; @@ -11,7 +11,7 @@ import java.util.concurrent.atomic.*; /** * AsyncActions that may be linked in parent-child relationships. * - *

Upon construction, an LinkedAsyncAction may register as a + *

Upon construction, an LinkedAsyncAction may register as a * subtask of a given parent task. In this case, completion of this * task will propagate to its parent. If the parent's pending subtask * completion count becomes zero, it too will complete. @@ -24,12 +24,12 @@ import java.util.concurrent.atomic.*; * complete of the subtask will trigger complete of the * parent without the parent explicitly doing so. * - *

In addition to supporting these different computation styles + *

In addition to supporting these different computation styles * compared to Recursive tasks, LinkedAsyncActions may have smaller * stack space footprints while executing, but may have greater * per-task overhead. * - *

Sample Usage. Here is a sketch of an LinkedAsyncAction + *

Sample Usage. Here is a sketch of an LinkedAsyncAction * that visits all of the nodes of a graph. The details of the graph's * Node and Edge classes are omitted, but we assume each node contains * an AtomicBoolean mark that starts out false. To execute @@ -39,24 +39,23 @@ import java.util.concurrent.atomic.*; * *

  * class GraphVisitor extends LinkedAsyncAction {
- *    final Node node;
- *    GraphVisitor(GraphVistor parent, Node node) {
- *      super(parent); this.node = node;
- *    }
- *    protected void compute() {
- *      if (node.mark.compareAndSet(false, true)) {
- *         for (Edge e : node.edges()) {
- *            Node dest = e.getDestination();
- *            if (!dest.mark.get())
- *               new GraphVisitor(this, dest).fork();
- *         }
- *         visit(node);
- *      }
- *      complete();
+ *   final Node node;
+ *   GraphVisitor(GraphVistor parent, Node node) {
+ *     super(parent); this.node = node;
+ *   }
+ *   protected void compute() {
+ *     if (node.mark.compareAndSet(false, true)) {
+ *       for (Edge e : node.edges()) {
+ *         Node dest = e.getDestination();
+ *         if (!dest.mark.get())
+ *           new GraphVisitor(this, dest).fork();
+ *       }
+ *       visit(node);
+ *     }
+ *     complete();
  *   }
  * }
  * 
- * */ public abstract class LinkedAsyncAction extends ForkJoinTask { @@ -85,7 +84,7 @@ public abstract class LinkedAsyncAction /** * Creates a new action with the given parent. If the parent is - * non-null, this tasks registers with the parent, in which case, + * non-null, this task registers with the parent, in which case, * the parent task cannot complete until this task completes. * @param parent the parent task, or null if none */ @@ -98,7 +97,7 @@ public abstract class LinkedAsyncAction /** * Creates a new action with the given parent, optionally * registering with the parent. If the parent is non-null and - * register is true, this tasks registers with the + * register is true, this task registers with the * parent, in which case, the parent task cannot complete until * this task completes. * @param parent the parent task, or null if none @@ -115,7 +114,7 @@ public abstract class LinkedAsyncAction * Creates a new action with the given parent, optionally * registering with the parent, and setting the pending join count * to the given value. If the parent is non-null and - * register is true, this tasks registers with the + * register is true, this task registers with the * parent, in which case, the parent task cannot complete until * this task completes. Setting the pending join count requires * care -- it is correct only if child tasks do not themselves @@ -141,7 +140,7 @@ public abstract class LinkedAsyncAction * Overridable callback action triggered by complete. Upon * invocation, all subtasks have completed. After return, this * task isDone and is joinable by other tasks. The - * default version of this method does nothing. But it may may be + * default version of this method does nothing. But it may be * overridden in subclasses to perform some action when this task * is about to complete. */ @@ -158,7 +157,7 @@ public abstract class LinkedAsyncAction * default version of this method does nothing and returns * true. * @return true if this task's exception should be propagated to - * this tasks parent. + * this task's parent. */ protected boolean onException() { return true; @@ -178,7 +177,7 @@ public abstract class LinkedAsyncAction * Completes this task. If the pending subtask completion count is * zero, invokes onCompletion, then causes this task to * be joinable (isDone becomes true), and then - * recursively applies to this tasks's parent, if it exists. If an + * recursively applies to this task's parent, if it exists. If an * exception is encountered in any onCompletion * invocation, that task and its ancestors * completeExceptionally.