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.13 by jsr166, Mon Nov 26 11:36:33 2012 UTC vs.
Revision 1.17 by dl, Sat Sep 12 18:11:24 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 57 | Line 57 | import java.util.concurrent.atomic.*;
57   * </pre>
58   */
59   public abstract class BinaryAsyncAction extends ForkJoinTask<Void> {
60    private volatile int controlState;
61
62    static final AtomicIntegerFieldUpdater<BinaryAsyncAction> controlStateUpdater =
63        AtomicIntegerFieldUpdater.newUpdater(BinaryAsyncAction.class, "controlState");
60  
61      /**
62       * Parent to propagate completion; nulled after completion to
# Line 89 | Line 85 | public abstract class BinaryAsyncAction
85       * as parent, and each other as siblings.
86       * @param x one subtask
87       * @param y the other subtask
88 <     * @throws NullPointerException if either argument is null.
88 >     * @throws NullPointerException if either argument is null
89       */
90      public final void linkSubtasks(BinaryAsyncAction x, BinaryAsyncAction y) {
91          x.parent = y.parent = this;
# Line 120 | Line 116 | public abstract class BinaryAsyncAction
116       * default version of this method does nothing and returns
117       * {@code true}.
118       * @return true if this task's exception should be propagated to
119 <     * this task's parent.
119 >     * this task's parent
120       */
121      protected boolean onException() {
122          return true;
# Line 169 | Line 165 | public abstract class BinaryAsyncAction
165              a.sibling = null;
166              a.parent = null;
167              a.completeThis();
168 <            if (p == null || p.compareAndSetControlState(0, 1))
168 >            if (p == null || p.markForkJoinTask())
169                  break;
170              try {
171                  p.onComplete(a, s);
# Line 192 | Line 188 | public abstract class BinaryAsyncAction
188       * @param ex the exception to throw when joining this task
189       * @throws NullPointerException if ex is null
190       * @throws Throwable if any invocation of
191 <     * {@code onException} does so.
191 >     * {@code onException} does so
192       */
193      public final void completeExceptionally(Throwable ex) {
194          BinaryAsyncAction a = this;
# Line 209 | Line 205 | public abstract class BinaryAsyncAction
205      /**
206       * Returns this task's parent, or null if none or this task
207       * is already complete.
208 <     * @return this task's parent, or null if none.
208 >     * @return this task's parent, or null if none
209       */
210      public final BinaryAsyncAction getParent() {
211          return parent;
# Line 218 | Line 214 | public abstract class BinaryAsyncAction
214      /**
215       * Returns this task's sibling, or null if none or this task is
216       * already complete.
217 <     * @return this task's sibling, or null if none.
217 >     * @return this task's sibling, or null if none
218       */
219      public BinaryAsyncAction getSibling() {
220          return sibling;
# Line 233 | Line 229 | public abstract class BinaryAsyncAction
229          super.reinitialize();
230      }
231  
232 + <<<<<<< BinaryAsyncAction.java
233 + =======
234      /**
235       * Gets the control state, which is initially zero, or negative if
236       * this task has completed or cancelled. Once negative, the value
# Line 267 | Line 265 | public abstract class BinaryAsyncAction
265      }
266  
267      /**
268 <     * Sets the control state to the given value,
268 >     * Increments the control state.
269       * @param value the new value
270       */
271      protected final void incrementControlState() {
# Line 275 | Line 273 | public abstract class BinaryAsyncAction
273      }
274  
275      /**
276 <     * Decrement the control state
276 >     * Decrements the control state.
277       * @return true if successful
278       */
279      protected final void decrementControlState() {
280          controlStateUpdater.decrementAndGet(this);
281      }
282 + >>>>>>> 1.14
283  
284   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines