8 |
|
import static java.util.concurrent.TimeUnit.SECONDS; |
9 |
|
|
10 |
|
import java.util.Arrays; |
11 |
+ |
import java.util.Collections; |
12 |
|
import java.util.concurrent.ExecutionException; |
13 |
|
import java.util.concurrent.ForkJoinPool; |
14 |
|
import java.util.concurrent.ForkJoinTask; |
874 |
|
} |
875 |
|
|
876 |
|
/** |
877 |
< |
* invokeAll(t1, t2) throw exception if any task does |
877 |
> |
* invokeAll(tasks) with 1 argument throws exception if task does |
878 |
|
*/ |
879 |
< |
public void testAbnormalInvokeAll2() { |
880 |
< |
testAbnormalInvokeAll2(mainPool()); |
879 |
> |
public void testAbnormalInvokeAll1() { |
880 |
> |
testAbnormalInvokeAll1(mainPool()); |
881 |
|
} |
882 |
< |
public void testAbnormalInvokeAll2_Singleton() { |
883 |
< |
testAbnormalInvokeAll2(singletonPool()); |
882 |
> |
public void testAbnormalInvokeAll1_Singleton() { |
883 |
> |
testAbnormalInvokeAll1(singletonPool()); |
884 |
|
} |
885 |
< |
public void testAbnormalInvokeAll2(ForkJoinPool pool) { |
885 |
> |
public void testAbnormalInvokeAll1(ForkJoinPool pool) { |
886 |
|
RecursiveAction a = new CheckedRecursiveAction() { |
887 |
|
protected void realCompute() { |
887 |
– |
AsyncFib f = new AsyncFib(8); |
888 |
|
FailingAsyncFib g = new FailingAsyncFib(9); |
889 |
|
try { |
890 |
< |
invokeAll(f, g); |
890 |
> |
invokeAll(g); |
891 |
|
shouldThrow(); |
892 |
|
} catch (FJException success) { |
893 |
|
checkCompletedAbnormally(g, success); |
897 |
|
} |
898 |
|
|
899 |
|
/** |
900 |
< |
* invokeAll(tasks) with 1 argument throws exception if task does |
900 |
> |
* invokeAll(t1, t2) throw exception if any task does |
901 |
|
*/ |
902 |
< |
public void testAbnormalInvokeAll1() { |
903 |
< |
testAbnormalInvokeAll1(mainPool()); |
902 |
> |
public void testAbnormalInvokeAll2() { |
903 |
> |
testAbnormalInvokeAll2(mainPool()); |
904 |
|
} |
905 |
< |
public void testAbnormalInvokeAll1_Singleton() { |
906 |
< |
testAbnormalInvokeAll1(singletonPool()); |
905 |
> |
public void testAbnormalInvokeAll2_Singleton() { |
906 |
> |
testAbnormalInvokeAll2(singletonPool()); |
907 |
|
} |
908 |
< |
public void testAbnormalInvokeAll1(ForkJoinPool pool) { |
908 |
> |
public void testAbnormalInvokeAll2(ForkJoinPool pool) { |
909 |
|
RecursiveAction a = new CheckedRecursiveAction() { |
910 |
|
protected void realCompute() { |
911 |
+ |
AsyncFib f = new AsyncFib(8); |
912 |
|
FailingAsyncFib g = new FailingAsyncFib(9); |
913 |
+ |
ForkJoinTask[] tasks = { f, g }; |
914 |
+ |
Collections.shuffle(Arrays.asList(tasks)); |
915 |
|
try { |
916 |
< |
invokeAll(g); |
916 |
> |
invokeAll(tasks[0], tasks[1]); |
917 |
|
shouldThrow(); |
918 |
|
} catch (FJException success) { |
919 |
|
checkCompletedAbnormally(g, success); |
937 |
|
AsyncFib f = new AsyncFib(8); |
938 |
|
FailingAsyncFib g = new FailingAsyncFib(9); |
939 |
|
AsyncFib h = new AsyncFib(7); |
940 |
+ |
ForkJoinTask[] tasks = { f, g, h }; |
941 |
+ |
Collections.shuffle(Arrays.asList(tasks)); |
942 |
|
try { |
943 |
< |
invokeAll(f, g, h); |
943 |
> |
invokeAll(tasks[0], tasks[1], tasks[2]); |
944 |
|
shouldThrow(); |
945 |
|
} catch (FJException success) { |
946 |
|
checkCompletedAbnormally(g, success); |
965 |
|
AsyncFib g = new AsyncFib(9); |
966 |
|
AsyncFib h = new AsyncFib(7); |
967 |
|
ForkJoinTask[] tasks = { f, g, h }; |
968 |
+ |
Collections.shuffle(Arrays.asList(tasks)); |
969 |
|
try { |
970 |
|
invokeAll(Arrays.asList(tasks)); |
971 |
|
shouldThrow(); |