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

Comparing jsr166/src/test/loops/BinaryAsyncAction.java (file contents):
Revision 1.12 by jsr166, Mon Nov 26 06:32:28 2012 UTC vs.
Revision 1.19 by jsr166, Sat Sep 12 19:29:06 2015 UTC

# Line 13 | Line 13 | import java.util.concurrent.atomic.*;
13   * have smaller stack space footprints and faster completion mechanics
14   * but higher per-task footprints. Compared to LinkedAsyncActions,
15   * BinaryAsyncActions are simpler to use and have less overhead in
16 < * typical uasges but are restricted to binary computation trees.
16 > * typical usages but are restricted to binary computation trees.
17   *
18   * <p>Upon construction, a BinaryAsyncAction does not bear any
19   * linkages. For non-root tasks, links must be established using
# Line 38 | Line 38 | import java.util.concurrent.atomic.*;
38   *   }
39   * }
40   * </pre>
41 < * An alternative, and usually faster strategy is to instead use a
41 > * An alternative, and usually faster, strategy is to instead use a
42   * loop to fork subtasks:
43   * <pre>
44   *   protected void compute() {
# Line 89 | Line 89 | public abstract class BinaryAsyncAction
89       * as parent, and each other as siblings.
90       * @param x one subtask
91       * @param y the other subtask
92 <     * @throws NullPointerException if either argument is null.
92 >     * @throws NullPointerException if either argument is null
93       */
94      public final void linkSubtasks(BinaryAsyncAction x, BinaryAsyncAction y) {
95          x.parent = y.parent = this;
# Line 120 | Line 120 | public abstract class BinaryAsyncAction
120       * default version of this method does nothing and returns
121       * {@code true}.
122       * @return true if this task's exception should be propagated to
123 <     * this task's parent.
123 >     * this task's parent
124       */
125      protected boolean onException() {
126          return true;
# Line 169 | Line 169 | public abstract class BinaryAsyncAction
169              a.sibling = null;
170              a.parent = null;
171              a.completeThis();
172 <            if (p == null || p.compareAndSetControlState(0, 1))
172 >            if (p == null ||  p.compareAndSetControlState(0, 1))
173                  break;
174              try {
175                  p.onComplete(a, s);
# Line 185 | Line 185 | public abstract class BinaryAsyncAction
185       * Completes this task abnormally. Unless this task already
186       * cancelled or aborted, upon invocation, this method invokes
187       * {@code onException}, and then, depending on its return value,
188 <     * completees parent (if one exists) exceptionally or normally.  To
188 >     * completes parent (if one exists) exceptionally or normally.  To
189       * avoid unbounded exception loops, this method aborts if an
190       * exception is encountered in any {@code onException}
191       * invocation.
192       * @param ex the exception to throw when joining this task
193       * @throws NullPointerException if ex is null
194       * @throws Throwable if any invocation of
195 <     * {@code onException} does so.
195 >     * {@code onException} does so
196       */
197      public final void completeExceptionally(Throwable ex) {
198          BinaryAsyncAction a = this;
# Line 209 | Line 209 | public abstract class BinaryAsyncAction
209      /**
210       * Returns this task's parent, or null if none or this task
211       * is already complete.
212 <     * @return this task's parent, or null if none.
212 >     * @return this task's parent, or null if none
213       */
214      public final BinaryAsyncAction getParent() {
215          return parent;
# Line 218 | Line 218 | public abstract class BinaryAsyncAction
218      /**
219       * Returns this task's sibling, or null if none or this task is
220       * already complete.
221 <     * @return this task's sibling, or null if none.
221 >     * @return this task's sibling, or null if none
222       */
223      public BinaryAsyncAction getSibling() {
224          return sibling;
# Line 267 | Line 267 | public abstract class BinaryAsyncAction
267      }
268  
269      /**
270 <     * Sets the control state to the given value,
270 >     * Increments the control state.
271       * @param value the new value
272       */
273      protected final void incrementControlState() {
# Line 275 | Line 275 | public abstract class BinaryAsyncAction
275      }
276  
277      /**
278 <     * Decrement the control state
278 >     * Decrements the control state.
279       * @return true if successful
280       */
281      protected final void decrementControlState() {
282          controlStateUpdater.decrementAndGet(this);
283      }
284  
285 +
286   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines