7 |
|
package jsr166y; |
8 |
|
|
9 |
|
/** |
10 |
< |
* Recursive resultless ForkJoinTasks. This class establishes |
11 |
< |
* conventions to parameterize resultless actions as {@code Void} |
12 |
< |
* ForkJoinTasks. Because {@code null} is the only valid value of |
13 |
< |
* type {@code Void}, methods such as join always return {@code null} |
14 |
< |
* upon completion. |
10 |
> |
* A recursive resultless {@link ForkJoinTask}. This class |
11 |
> |
* establishes conventions to parameterize resultless actions as |
12 |
> |
* {@code Void} {@code ForkJoinTask}s. Because {@code null} is the |
13 |
> |
* only valid value of type {@code Void}, methods such as join always |
14 |
> |
* return {@code null} upon completion. |
15 |
|
* |
16 |
|
* <p><b>Sample Usages.</b> Here is a sketch of a ForkJoin sort that |
17 |
|
* sorts a given {@code long[]} array: |
34 |
|
* } |
35 |
|
* }}</pre> |
36 |
|
* |
37 |
< |
* You could then sort anArray by creating {@code new SortTask(anArray, 0, |
38 |
< |
* anArray.length-1) } and invoking it in a ForkJoinPool. |
39 |
< |
* As a more concrete simple example, the following task increments |
40 |
< |
* each element of an array: |
37 |
> |
* You could then sort {@code anArray} by creating {@code new |
38 |
> |
* SortTask(anArray, 0, anArray.length-1) } and invoking it in a |
39 |
> |
* ForkJoinPool. As a more concrete simple example, the following |
40 |
> |
* task increments each element of an array: |
41 |
|
* <pre> {@code |
42 |
|
* class IncrementTask extends RecursiveAction { |
43 |
|
* final long[] array; final int lo; final int hi; |
98 |
|
* int l = lo; |
99 |
|
* int h = hi; |
100 |
|
* Applyer right = null; |
101 |
< |
* while (h - l > 1 && |
102 |
< |
* ForkJoinWorkerThread.getEstimatedSurplusTaskCount() <= 3) { |
101 |
> |
* while (h - l > 1 && getSurplusQueuedTaskCount() <= 3) { |
102 |
|
* int mid = (l + h) >>> 1; |
103 |
|
* right = new Applyer(array, mid, h, seqSize, right); |
104 |
|
* right.fork(); |
122 |
|
* @author Doug Lea |
123 |
|
*/ |
124 |
|
public abstract class RecursiveAction extends ForkJoinTask<Void> { |
125 |
+ |
private static final long serialVersionUID = 5232453952276485070L; |
126 |
|
|
127 |
|
/** |
128 |
|
* The main computation performed by this task. |