ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/LinkedAsyncAction.java
(Generate patch)

Comparing jsr166/src/test/loops/LinkedAsyncAction.java (file contents):
Revision 1.9 by jsr166, Mon Nov 26 05:59:05 2012 UTC vs.
Revision 1.10 by jsr166, Mon Nov 26 06:32:28 2012 UTC

# Line 15 | Line 15 | import java.util.concurrent.atomic.*;
15   * subtask of a given parent task. In this case, completion of this
16   * task will propagate to its parent. If the parent's pending subtask
17   * completion count becomes zero, it too will complete.
18 < * LinkedAsyncActions rarely use methods <tt>join</tt> or
19 < * <tt>invoke</tt> but instead propagate completion to parents
20 < * implicitly via <tt>complete</tt>.  While typical, it is not necessary
21 < * for each task to <tt>complete</tt> itself. For example, it is
18 > * LinkedAsyncActions rarely use methods {@code join} or
19 > * {@code invoke} but instead propagate completion to parents
20 > * implicitly via {@code complete}.  While typical, it is not necessary
21 > * for each task to {@code complete} itself. For example, it is
22   * possible to treat one subtask as a continuation of the current task
23   * by not registering it on construction.  In this case, a
24 < * <tt>complete</tt> of the subtask will trigger <tt>complete</tt> of the
24 > * {@code complete} of the subtask will trigger {@code complete} of the
25   * parent without the parent explicitly doing so.
26   *
27   * <p>In addition to supporting these different computation styles
# Line 32 | Line 32 | import java.util.concurrent.atomic.*;
32   * <p><b>Sample Usage.</b> Here is a sketch of a LinkedAsyncAction
33   * that visits all of the nodes of a graph. The details of the graph's
34   * Node and Edge classes are omitted, but we assume each node contains
35 < * an <tt>AtomicBoolean</tt> mark that starts out false. To execute
35 > * an {@code AtomicBoolean} mark that starts out false. To execute
36   * this, you would create a GraphVisitor for the root node with null
37 < * parent, and <tt>invoke</tt> in a ForkJoinPool. Upon return, all
37 > * parent, and {@code invoke} in a ForkJoinPool. Upon return, all
38   * reachable nodes will have been visited.
39   *
40   * <pre>
# Line 77 | Line 77 | public abstract class LinkedAsyncAction
77  
78      /**
79       * Creates a new action with no parent. (You can add a parent
80 <     * later (but before forking) via <tt>reinitialize</tt>).
80 >     * later (but before forking) via {@code reinitialize}).
81       */
82      protected LinkedAsyncAction() {
83      }
# Line 97 | Line 97 | public abstract class LinkedAsyncAction
97      /**
98       * Creates a new action with the given parent, optionally
99       * registering with the parent. If the parent is non-null and
100 <     * <tt>register</tt> is true, this task registers with the
100 >     * {@code register} is true, this task registers with the
101       * parent, in which case, the parent task cannot complete until
102       * this task completes.
103       * @param parent the parent task, or null if none
# Line 114 | Line 114 | public abstract class LinkedAsyncAction
114       * Creates a new action with the given parent, optionally
115       * registering with the parent, and setting the pending join count
116       * to the given value. If the parent is non-null and
117 <     * <tt>register</tt> is true, this task registers with the
117 >     * {@code register} is true, this task registers with the
118       * parent, in which case, the parent task cannot complete until
119       * this task completes. Setting the pending join count requires
120       * care -- it is correct only if child tasks do not themselves
# Line 137 | Line 137 | public abstract class LinkedAsyncAction
137      protected final void setRawResult(Void mustBeNull) { }
138  
139      /**
140 <     * Overridable callback action triggered by <tt>complete</tt>.  Upon
140 >     * Overridable callback action triggered by {@code complete}.  Upon
141       * invocation, all subtasks have completed.  After return, this
142 <     * task <tt>isDone</tt> and is joinable by other tasks. The
142 >     * task {@code isDone} and is joinable by other tasks. The
143       * default version of this method does nothing. But it may be
144       * overridden in subclasses to perform some action when this task
145       * is about to complete.
# Line 149 | Line 149 | public abstract class LinkedAsyncAction
149  
150      /**
151       * Overridable callback action triggered by
152 <     * <tt>completeExceptionally</tt>.  Upon invocation, this task has
152 >     * {@code completeExceptionally}.  Upon invocation, this task has
153       * aborted due to an exception (accessible via
154 <     * <tt>getException</tt>). If this method returns <tt>true</tt>,
154 >     * {@code getException}). If this method returns {@code true},
155       * the exception propagates to the current task's
156       * parent. Otherwise, normal completion is propagated.  The
157       * default version of this method does nothing and returns
158 <     * <tt>true</tt>.
158 >     * {@code true}.
159       * @return true if this task's exception should be propagated to
160       * this task's parent.
161       */
# Line 175 | Line 175 | public abstract class LinkedAsyncAction
175  
176      /**
177       * Completes this task. If the pending subtask completion count is
178 <     * zero, invokes <tt>onCompletion</tt>, then causes this task to
179 <     * be joinable (<tt>isDone</tt> becomes true), and then
178 >     * zero, invokes {@code onCompletion}, then causes this task to
179 >     * be joinable ({@code isDone} becomes true), and then
180       * recursively applies to this task's parent, if it exists. If an
181 <     * exception is encountered in any <tt>onCompletion</tt>
181 >     * exception is encountered in any {@code onCompletion}
182       * invocation, that task and its ancestors
183 <     * <tt>completeExceptionally</tt>.
183 >     * {@code completeExceptionally}.
184       */
185      public final void complete() {
186          LinkedAsyncAction a = this;
# Line 204 | Line 204 | public abstract class LinkedAsyncAction
204      /**
205       * Completes this task abnormally. Unless this task already
206       * cancelled or aborted, upon invocation, this method invokes
207 <     * <tt>onException</tt>, and then, depending on its return value,
207 >     * {@code onException}, and then, depending on its return value,
208       * completees parent (if one exists) exceptionally or normally.  To
209       * avoid unbounded exception loops, this method aborts if an
210 <     * exception is encountered in any <tt>onException</tt>
210 >     * exception is encountered in any {@code onException}
211       * invocation.
212       * @param ex the exception to throw when joining this task
213       * @throws NullPointerException if ex is null
214       * @throws Throwable if any invocation of
215 <     * <tt>onException</tt> does so.
215 >     * {@code onException} does so.
216       */
217      public final void completeExceptionally(Throwable ex) {
218          LinkedAsyncAction a = this;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines