3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
|
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
+ |
import java.util.HashSet; |
7 |
|
import java.util.concurrent.ExecutionException; |
7 |
– |
import java.util.concurrent.CancellationException; |
8 |
|
import java.util.concurrent.ForkJoinPool; |
9 |
|
import java.util.concurrent.ForkJoinTask; |
10 |
– |
import java.util.concurrent.ForkJoinWorkerThread; |
10 |
|
import java.util.concurrent.RecursiveAction; |
12 |
– |
import java.util.concurrent.TimeUnit; |
11 |
|
import java.util.concurrent.TimeoutException; |
14 |
– |
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; |
12 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
13 |
|
import static java.util.concurrent.TimeUnit.SECONDS; |
17 |
– |
import java.util.HashSet; |
14 |
|
import junit.framework.*; |
15 |
|
|
16 |
|
public class ForkJoinTask8Test extends JSR166TestCase { |
28 |
|
static final short INITIAL_STATE = -1; |
29 |
|
static final short COMPLETE_STATE = 0; |
30 |
|
static final short EXCEPTION_STATE = 1; |
35 |
– |
|
31 |
|
|
32 |
|
public static void main(String[] args) { |
33 |
|
junit.textui.TestRunner.run(suite()); |
201 |
|
} |
202 |
|
|
203 |
|
protected void onComplete(BinaryAsyncAction x, BinaryAsyncAction y) { |
204 |
< |
if (this.getForkJoinTaskTag() != COMPLETE_STATE || |
205 |
< |
x.getForkJoinTaskTag() != COMPLETE_STATE || |
204 |
> |
if (this.getForkJoinTaskTag() != COMPLETE_STATE || |
205 |
> |
x.getForkJoinTaskTag() != COMPLETE_STATE || |
206 |
|
y.getForkJoinTaskTag() != COMPLETE_STATE) { |
207 |
|
completeThisExceptionally(new FJException()); |
208 |
|
} |
236 |
|
a.sibling = null; |
237 |
|
a.parent = null; |
238 |
|
a.completeThis(); |
239 |
< |
if (p == null || |
239 |
> |
if (p == null || |
240 |
|
p.compareAndSetForkJoinTaskTag(INITIAL_STATE, COMPLETE_STATE)) |
241 |
|
break; |
242 |
|
try { |
274 |
|
super.reinitialize(); |
275 |
|
} |
276 |
|
|
282 |
– |
|
277 |
|
} |
278 |
|
|
279 |
|
static final class AsyncFib extends BinaryAsyncAction { |
298 |
|
} |
299 |
|
f.complete(); |
300 |
|
} |
301 |
< |
catch(Throwable ex) { |
301 |
> |
catch (Throwable ex) { |
302 |
|
compareAndSetForkJoinTaskTag(INITIAL_STATE, EXCEPTION_STATE); |
303 |
|
} |
304 |
|
return false; |
567 |
|
testInvokeOnPool(mainPool(), a); |
568 |
|
} |
569 |
|
|
576 |
– |
|
570 |
|
/** |
571 |
|
* getPool of executing task returns its pool |
572 |
|
*/ |
789 |
|
} |
790 |
|
|
791 |
|
/** |
792 |
< |
* invokeAll(collection) throws exception if any task does |
792 |
> |
* invokeAll(collection) throws exception if any task does |
793 |
|
*/ |
794 |
|
public void testAbnormalInvokeAllCollection() { |
795 |
|
RecursiveAction a = new CheckedRecursiveAction() { |
1366 |
|
} |
1367 |
|
|
1368 |
|
/** |
1369 |
< |
* invokeAll(collection) throws exception if any task does |
1369 |
> |
* invokeAll(collection) throws exception if any task does |
1370 |
|
*/ |
1371 |
|
public void testAbnormalInvokeAllCollectionSingleton() { |
1372 |
|
RecursiveAction a = new CheckedRecursiveAction() { |
1388 |
|
testInvokeOnPool(singletonPool(), a); |
1389 |
|
} |
1390 |
|
|
1398 |
– |
|
1391 |
|
/** |
1392 |
|
* ForkJoinTask.quietlyComplete returns when task completes |
1393 |
|
* normally without setting a value. The most recent value |