59 |
|
* RecursiveAction and CountedCompleter, but with all actions |
60 |
|
* executed in the common pool, generally implicitly via |
61 |
|
* checkInvoke. |
62 |
< |
*/ |
62 |
> |
*/ |
63 |
|
|
64 |
|
private void checkInvoke(ForkJoinTask a) { |
65 |
|
checkNotDone(a); |
403 |
|
} |
404 |
|
|
405 |
|
/** |
406 |
– |
* helpQuiesce returns when tasks are complete. |
407 |
– |
* getQueuedTaskCount returns 0 when quiescent |
408 |
– |
*/ |
409 |
– |
public void testForkHelpQuiesce() { |
410 |
– |
RecursiveAction a = new CheckedRecursiveAction() { |
411 |
– |
public void realCompute() { |
412 |
– |
FibAction f = new FibAction(8); |
413 |
– |
assertSame(f, f.fork()); |
414 |
– |
helpQuiesce(); |
415 |
– |
assertEquals(21, f.result); |
416 |
– |
assertEquals(0, getQueuedTaskCount()); |
417 |
– |
checkCompletedNormally(f); |
418 |
– |
}}; |
419 |
– |
checkInvoke(a); |
420 |
– |
} |
421 |
– |
|
422 |
– |
/** |
406 |
|
* invoke task throws exception when task completes abnormally |
407 |
|
*/ |
408 |
|
public void testAbnormalInvoke() { |
872 |
|
} |
873 |
|
} |
874 |
|
|
875 |
< |
static abstract class CCF extends CountedCompleter { |
875 |
> |
abstract static class CCF extends CountedCompleter { |
876 |
|
int number; |
877 |
|
int rnumber; |
878 |
|
|
893 |
|
f.onCompletion(f); |
894 |
|
if ((p = f.getCompleter()) != null) |
895 |
|
p.tryComplete(); |
896 |
< |
else |
897 |
< |
f.quietlyComplete(); |
896 |
> |
else |
897 |
> |
f.quietlyComplete(); |
898 |
|
} |
899 |
|
} |
900 |
|
|
926 |
|
} |
927 |
|
|
928 |
|
// Version of CCF with forced failure in left completions |
929 |
< |
static abstract class FailingCCF extends CountedCompleter { |
929 |
> |
abstract static class FailingCCF extends CountedCompleter { |
930 |
|
int number; |
931 |
|
int rnumber; |
932 |
|
|
947 |
|
f.onCompletion(f); |
948 |
|
if ((p = f.getCompleter()) != null) |
949 |
|
p.tryComplete(); |
950 |
< |
else |
951 |
< |
f.quietlyComplete(); |
950 |
> |
else |
951 |
> |
f.quietlyComplete(); |
952 |
|
} |
953 |
|
} |
954 |
|
|
973 |
|
completeExceptionally(new FJException()); |
974 |
|
} |
975 |
|
} |
976 |
< |
|
976 |
> |
|
977 |
|
/** |
978 |
|
* invoke returns when task completes normally. |
979 |
|
* isCompletedAbnormally and isCancelled return false for normally |
1080 |
|
checkCompletedNormally(f); |
1081 |
|
}}; |
1082 |
|
checkInvoke(a); |
1100 |
– |
} |
1101 |
– |
|
1102 |
– |
/** |
1103 |
– |
* helpQuiesce returns when tasks are complete. |
1104 |
– |
* getQueuedTaskCount returns 0 when quiescent |
1105 |
– |
*/ |
1106 |
– |
public void testForkHelpQuiesceCC() { |
1107 |
– |
ForkJoinTask a = new CheckedFJTask() { |
1108 |
– |
public void realCompute() { |
1109 |
– |
CCF f = new LCCF(null, 8); |
1110 |
– |
assertSame(f, f.fork()); |
1111 |
– |
helpQuiesce(); |
1112 |
– |
assertEquals(21, f.number); |
1113 |
– |
assertEquals(0, getQueuedTaskCount()); |
1114 |
– |
checkCompletedNormally(f); |
1115 |
– |
}}; |
1116 |
– |
checkInvoke(a); |
1083 |
|
} |
1084 |
|
|
1085 |
|
/** |