jdk/src/share/classes/java/util/concurrent/RecursiveAction.java
author dl
Mon, 02 Nov 2009 17:25:38 -0800
changeset 4110 ac033ba6ede4
child 5506 202f599c92aa
permissions -rw-r--r--
6865582: jsr166y - jsr166 maintenance update 6865571: Add a lightweight task framework known as ForkJoin 6445158: Phaser - an improved CyclicBarrier 6865579: Add TransferQueue/LinkedTransferQueue Reviewed-by: martin, chegar, dice
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4110
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     1
/*
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     3
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Sun designates this
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     8
 * by Sun in the LICENSE file that accompanied this code.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
     9
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    14
 * accompanied this code).
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    15
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    19
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    20
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    21
 * CA 95054 USA or visit www.sun.com if you need additional information or
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    22
 * have any questions.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    23
 */
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    24
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    25
/*
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    26
 * This file is available under and governed by the GNU General Public
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    27
 * License version 2 only, as published by the Free Software Foundation.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    28
 * However, the following notice accompanied the original version of this
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    29
 * file:
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    30
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    31
 * Written by Doug Lea with assistance from members of JCP JSR-166
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    32
 * Expert Group and released to the public domain, as explained at
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    33
 * http://creativecommons.org/licenses/publicdomain
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    34
 */
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    35
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    36
package java.util.concurrent;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    37
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    38
/**
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    39
 * A recursive resultless {@link ForkJoinTask}.  This class
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    40
 * establishes conventions to parameterize resultless actions as
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    41
 * {@code Void} {@code ForkJoinTask}s. Because {@code null} is the
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    42
 * only valid value of type {@code Void}, methods such as join always
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    43
 * return {@code null} upon completion.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    44
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    45
 * <p><b>Sample Usages.</b> Here is a sketch of a ForkJoin sort that
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    46
 * sorts a given {@code long[]} array:
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    47
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    48
 *  <pre> {@code
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    49
 * class SortTask extends RecursiveAction {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    50
 *   final long[] array; final int lo; final int hi;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    51
 *   SortTask(long[] array, int lo, int hi) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    52
 *     this.array = array; this.lo = lo; this.hi = hi;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    53
 *   }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    54
 *   protected void compute() {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    55
 *     if (hi - lo < THRESHOLD)
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    56
 *       sequentiallySort(array, lo, hi);
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    57
 *     else {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    58
 *       int mid = (lo + hi) >>> 1;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    59
 *       invokeAll(new SortTask(array, lo, mid),
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    60
 *                 new SortTask(array, mid, hi));
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    61
 *       merge(array, lo, hi);
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    62
 *     }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    63
 *   }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    64
 * }}</pre>
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    65
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    66
 * You could then sort {@code anArray} by creating {@code new
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    67
 * SortTask(anArray, 0, anArray.length-1) } and invoking it in a
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    68
 * ForkJoinPool.  As a more concrete simple example, the following
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    69
 * task increments each element of an array:
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    70
 *  <pre> {@code
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    71
 * class IncrementTask extends RecursiveAction {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    72
 *   final long[] array; final int lo; final int hi;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    73
 *   IncrementTask(long[] array, int lo, int hi) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    74
 *     this.array = array; this.lo = lo; this.hi = hi;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    75
 *   }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    76
 *   protected void compute() {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    77
 *     if (hi - lo < THRESHOLD) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    78
 *       for (int i = lo; i < hi; ++i)
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    79
 *         array[i]++;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    80
 *     }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    81
 *     else {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    82
 *       int mid = (lo + hi) >>> 1;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    83
 *       invokeAll(new IncrementTask(array, lo, mid),
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    84
 *                 new IncrementTask(array, mid, hi));
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    85
 *     }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    86
 *   }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    87
 * }}</pre>
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    88
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    89
 * <p>The following example illustrates some refinements and idioms
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    90
 * that may lead to better performance: RecursiveActions need not be
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    91
 * fully recursive, so long as they maintain the basic
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    92
 * divide-and-conquer approach. Here is a class that sums the squares
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    93
 * of each element of a double array, by subdividing out only the
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    94
 * right-hand-sides of repeated divisions by two, and keeping track of
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    95
 * them with a chain of {@code next} references. It uses a dynamic
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    96
 * threshold based on method {@code getSurplusQueuedTaskCount}, but
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    97
 * counterbalances potential excess partitioning by directly
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    98
 * performing leaf actions on unstolen tasks rather than further
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
    99
 * subdividing.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   100
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   101
 *  <pre> {@code
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   102
 * double sumOfSquares(ForkJoinPool pool, double[] array) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   103
 *   int n = array.length;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   104
 *   Applyer a = new Applyer(array, 0, n, null);
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   105
 *   pool.invoke(a);
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   106
 *   return a.result;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   107
 * }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   108
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   109
 * class Applyer extends RecursiveAction {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   110
 *   final double[] array;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   111
 *   final int lo, hi;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   112
 *   double result;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   113
 *   Applyer next; // keeps track of right-hand-side tasks
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   114
 *   Applyer(double[] array, int lo, int hi, Applyer next) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   115
 *     this.array = array; this.lo = lo; this.hi = hi;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   116
 *     this.next = next;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   117
 *   }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   118
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   119
 *   double atLeaf(int l, int h) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   120
 *     double sum = 0;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   121
 *     for (int i = l; i < h; ++i) // perform leftmost base step
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   122
 *       sum += array[i] * array[i];
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   123
 *     return sum;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   124
 *   }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   125
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   126
 *   protected void compute() {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   127
 *     int l = lo;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   128
 *     int h = hi;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   129
 *     Applyer right = null;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   130
 *     while (h - l > 1 && getSurplusQueuedTaskCount() <= 3) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   131
 *        int mid = (l + h) >>> 1;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   132
 *        right = new Applyer(array, mid, h, right);
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   133
 *        right.fork();
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   134
 *        h = mid;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   135
 *     }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   136
 *     double sum = atLeaf(l, h);
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   137
 *     while (right != null) {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   138
 *        if (right.tryUnfork()) // directly calculate if not stolen
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   139
 *          sum += right.atLeaf(right.lo, right.hi);
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   140
 *       else {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   141
 *          right.helpJoin();
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   142
 *          sum += right.result;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   143
 *        }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   144
 *        right = right.next;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   145
 *      }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   146
 *     result = sum;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   147
 *   }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   148
 * }}</pre>
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   149
 *
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   150
 * @since 1.7
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   151
 * @author Doug Lea
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   152
 */
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   153
public abstract class RecursiveAction extends ForkJoinTask<Void> {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   154
    private static final long serialVersionUID = 5232453952276485070L;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   155
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   156
    /**
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   157
     * The main computation performed by this task.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   158
     */
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   159
    protected abstract void compute();
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   160
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   161
    /**
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   162
     * Always returns null.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   163
     */
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   164
    public final Void getRawResult() { return null; }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   165
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   166
    /**
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   167
     * Requires null completion value.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   168
     */
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   169
    protected final void setRawResult(Void mustBeNull) { }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   170
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   171
    /**
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   172
     * Implements execution conventions for RecursiveActions.
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   173
     */
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   174
    protected final boolean exec() {
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   175
        compute();
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   176
        return true;
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   177
    }
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   178
ac033ba6ede4 6865582: jsr166y - jsr166 maintenance update
dl
parents:
diff changeset
   179
}