20 |
|
public class RecursiveTaskTest extends JSR166TestCase { |
21 |
|
|
22 |
|
public static void main(String[] args) { |
23 |
< |
junit.textui.TestRunner.run(suite()); |
23 |
> |
main(suite(), args); |
24 |
|
} |
25 |
|
public static Test suite() { |
26 |
|
return new TestSuite(RecursiveTaskTest.class); |
41 |
|
} |
42 |
|
|
43 |
|
private <T> T testInvokeOnPool(ForkJoinPool pool, RecursiveTask<T> a) { |
44 |
< |
try { |
44 |
> |
try (PoolCleaner cleaner = cleaner(pool)) { |
45 |
|
checkNotDone(a); |
46 |
|
|
47 |
|
T result = pool.invoke(a); |
48 |
|
|
49 |
|
checkCompletedNormally(a, result); |
50 |
|
return result; |
51 |
– |
} finally { |
52 |
– |
joinPool(pool); |
51 |
|
} |
52 |
|
} |
53 |
|
|
183 |
|
public FJException() { super(); } |
184 |
|
} |
185 |
|
|
186 |
< |
// An invalid return value for Fib |
186 |
> |
/** An invalid return value for Fib. */ |
187 |
|
static final Integer NoResult = Integer.valueOf(-17); |
188 |
|
|
189 |
< |
// A simple recursive task for testing |
189 |
> |
/** A simple recursive task for testing. */ |
190 |
|
final class FibTask extends CheckedRecursiveTask<Integer> { |
191 |
|
final int number; |
192 |
|
FibTask(int n) { number = n; } |
204 |
|
} |
205 |
|
} |
206 |
|
|
207 |
< |
// A recursive action failing in base case |
207 |
> |
/** A recursive action failing in base case. */ |
208 |
|
final class FailingFibTask extends RecursiveTask<Integer> { |
209 |
|
final int number; |
210 |
|
int result; |
328 |
|
FibTask f = new FibTask(8); |
329 |
|
assertSame(f, f.fork()); |
330 |
|
helpQuiesce(); |
331 |
+ |
while (!f.isDone()) // wait out race |
332 |
+ |
; |
333 |
|
assertEquals(0, getQueuedTaskCount()); |
334 |
|
checkCompletedNormally(f, 21); |
335 |
|
return NoResult; |