1 |
|
/* |
2 |
|
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
< |
* http://creativecommons.org/licenses/publicdomain |
4 |
> |
* http://creativecommons.org/publicdomain/zero/1.0/ |
5 |
|
*/ |
6 |
– |
import junit.framework.*; |
7 |
– |
import java.util.concurrent.*; |
8 |
– |
import java.util.*; |
6 |
|
|
7 |
+ |
import junit.framework.*; |
8 |
+ |
import java.util.concurrent.CancellationException; |
9 |
+ |
import java.util.concurrent.ExecutionException; |
10 |
+ |
import java.util.concurrent.ForkJoinPool; |
11 |
+ |
import java.util.concurrent.ForkJoinTask; |
12 |
+ |
import java.util.concurrent.ForkJoinWorkerThread; |
13 |
+ |
import java.util.concurrent.RecursiveTask; |
14 |
+ |
import java.util.concurrent.TimeUnit; |
15 |
+ |
import java.util.concurrent.TimeoutException; |
16 |
+ |
import static java.util.concurrent.TimeUnit.SECONDS; |
17 |
+ |
import java.util.HashSet; |
18 |
|
|
19 |
|
public class RecursiveTaskTest extends JSR166TestCase { |
20 |
|
|
21 |
|
public static void main(String[] args) { |
22 |
< |
junit.textui.TestRunner.run (suite()); |
22 |
> |
junit.textui.TestRunner.run(suite()); |
23 |
|
} |
24 |
|
public static Test suite() { |
25 |
< |
return new TestSuite(RecursiveTaskTest.class); |
25 |
> |
return new TestSuite(RecursiveTaskTest.class); |
26 |
> |
} |
27 |
> |
|
28 |
> |
private static ForkJoinPool mainPool() { |
29 |
> |
return new ForkJoinPool(); |
30 |
|
} |
31 |
|
|
32 |
< |
static final ForkJoinPool mainPool = new ForkJoinPool(); |
33 |
< |
static final ForkJoinPool singletonPool = new ForkJoinPool(1); |
22 |
< |
static final ForkJoinPool asyncSingletonPool = new ForkJoinPool(1); |
23 |
< |
static { |
24 |
< |
asyncSingletonPool.setAsyncMode(true); |
32 |
> |
private static ForkJoinPool singletonPool() { |
33 |
> |
return new ForkJoinPool(1); |
34 |
|
} |
35 |
|
|
36 |
< |
static final class FJException extends RuntimeException { |
37 |
< |
FJException() { super(); } |
36 |
> |
private static ForkJoinPool asyncSingletonPool() { |
37 |
> |
return new ForkJoinPool(1, |
38 |
> |
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
39 |
> |
null, true); |
40 |
> |
} |
41 |
> |
|
42 |
> |
private <T> T testInvokeOnPool(ForkJoinPool pool, RecursiveTask<T> a) { |
43 |
> |
try { |
44 |
> |
checkNotDone(a); |
45 |
> |
|
46 |
> |
T result = pool.invoke(a); |
47 |
> |
|
48 |
> |
checkCompletedNormally(a, result); |
49 |
> |
return result; |
50 |
> |
} finally { |
51 |
> |
joinPool(pool); |
52 |
> |
} |
53 |
> |
} |
54 |
> |
|
55 |
> |
void checkNotDone(RecursiveTask a) { |
56 |
> |
assertFalse(a.isDone()); |
57 |
> |
assertFalse(a.isCompletedNormally()); |
58 |
> |
assertFalse(a.isCompletedAbnormally()); |
59 |
> |
assertFalse(a.isCancelled()); |
60 |
> |
assertNull(a.getException()); |
61 |
> |
assertNull(a.getRawResult()); |
62 |
> |
|
63 |
> |
if (! ForkJoinTask.inForkJoinPool()) { |
64 |
> |
Thread.currentThread().interrupt(); |
65 |
> |
try { |
66 |
> |
a.get(); |
67 |
> |
shouldThrow(); |
68 |
> |
} catch (InterruptedException success) { |
69 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
70 |
> |
|
71 |
> |
Thread.currentThread().interrupt(); |
72 |
> |
try { |
73 |
> |
a.get(5L, SECONDS); |
74 |
> |
shouldThrow(); |
75 |
> |
} catch (InterruptedException success) { |
76 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
77 |
> |
} |
78 |
> |
|
79 |
> |
try { |
80 |
> |
a.get(0L, SECONDS); |
81 |
> |
shouldThrow(); |
82 |
> |
} catch (TimeoutException success) { |
83 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
84 |
> |
} |
85 |
> |
|
86 |
> |
<T> void checkCompletedNormally(RecursiveTask<T> a, T expected) { |
87 |
> |
assertTrue(a.isDone()); |
88 |
> |
assertFalse(a.isCancelled()); |
89 |
> |
assertTrue(a.isCompletedNormally()); |
90 |
> |
assertFalse(a.isCompletedAbnormally()); |
91 |
> |
assertNull(a.getException()); |
92 |
> |
assertSame(expected, a.getRawResult()); |
93 |
> |
assertSame(expected, a.join()); |
94 |
> |
assertFalse(a.cancel(false)); |
95 |
> |
assertFalse(a.cancel(true)); |
96 |
> |
try { |
97 |
> |
assertSame(expected, a.get()); |
98 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
99 |
> |
try { |
100 |
> |
assertSame(expected, a.get(5L, SECONDS)); |
101 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
102 |
> |
} |
103 |
> |
|
104 |
> |
/** |
105 |
> |
* Waits for the task to complete, and checks that when it does, |
106 |
> |
* it will have an Integer result equals to the given int. |
107 |
> |
*/ |
108 |
> |
void checkCompletesNormally(RecursiveTask<Integer> a, int expected) { |
109 |
> |
Integer r = a.join(); |
110 |
> |
assertEquals(expected, (int) r); |
111 |
> |
checkCompletedNormally(a, r); |
112 |
> |
} |
113 |
> |
|
114 |
> |
/** |
115 |
> |
* Like checkCompletesNormally, but verifies that the task has |
116 |
> |
* already completed. |
117 |
> |
*/ |
118 |
> |
void checkCompletedNormally(RecursiveTask<Integer> a, int expected) { |
119 |
> |
Integer r = a.getRawResult(); |
120 |
> |
assertEquals(expected, (int) r); |
121 |
> |
checkCompletedNormally(a, r); |
122 |
> |
} |
123 |
> |
|
124 |
> |
void checkCancelled(RecursiveTask a) { |
125 |
> |
assertTrue(a.isDone()); |
126 |
> |
assertTrue(a.isCancelled()); |
127 |
> |
assertFalse(a.isCompletedNormally()); |
128 |
> |
assertTrue(a.isCompletedAbnormally()); |
129 |
> |
assertTrue(a.getException() instanceof CancellationException); |
130 |
> |
assertNull(a.getRawResult()); |
131 |
> |
|
132 |
> |
try { |
133 |
> |
a.join(); |
134 |
> |
shouldThrow(); |
135 |
> |
} catch (CancellationException success) { |
136 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
137 |
> |
|
138 |
> |
try { |
139 |
> |
a.get(); |
140 |
> |
shouldThrow(); |
141 |
> |
} catch (CancellationException success) { |
142 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
143 |
> |
|
144 |
> |
try { |
145 |
> |
a.get(5L, SECONDS); |
146 |
> |
shouldThrow(); |
147 |
> |
} catch (CancellationException success) { |
148 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
149 |
> |
} |
150 |
> |
|
151 |
> |
void checkCompletedAbnormally(RecursiveTask a, Throwable t) { |
152 |
> |
assertTrue(a.isDone()); |
153 |
> |
assertFalse(a.isCancelled()); |
154 |
> |
assertFalse(a.isCompletedNormally()); |
155 |
> |
assertTrue(a.isCompletedAbnormally()); |
156 |
> |
assertSame(t.getClass(), a.getException().getClass()); |
157 |
> |
assertNull(a.getRawResult()); |
158 |
> |
assertFalse(a.cancel(false)); |
159 |
> |
assertFalse(a.cancel(true)); |
160 |
> |
|
161 |
> |
try { |
162 |
> |
a.join(); |
163 |
> |
shouldThrow(); |
164 |
> |
} catch (Throwable expected) { |
165 |
> |
assertSame(t.getClass(), expected.getClass()); |
166 |
> |
} |
167 |
> |
|
168 |
> |
try { |
169 |
> |
a.get(); |
170 |
> |
shouldThrow(); |
171 |
> |
} catch (ExecutionException success) { |
172 |
> |
assertSame(t.getClass(), success.getCause().getClass()); |
173 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
174 |
> |
|
175 |
> |
try { |
176 |
> |
a.get(5L, SECONDS); |
177 |
> |
shouldThrow(); |
178 |
> |
} catch (ExecutionException success) { |
179 |
> |
assertSame(t.getClass(), success.getCause().getClass()); |
180 |
> |
} catch (Throwable fail) { threadUnexpectedException(fail); } |
181 |
> |
} |
182 |
> |
|
183 |
> |
public static final class FJException extends RuntimeException { |
184 |
> |
public FJException() { super(); } |
185 |
|
} |
186 |
|
|
187 |
|
// An invalid return value for Fib |
188 |
|
static final Integer NoResult = Integer.valueOf(-17); |
189 |
|
|
190 |
|
// A simple recursive task for testing |
191 |
< |
static final class FibTask extends RecursiveTask<Integer> { |
191 |
> |
final class FibTask extends CheckedRecursiveTask<Integer> { |
192 |
|
final int number; |
193 |
|
FibTask(int n) { number = n; } |
194 |
< |
public Integer compute() { |
194 |
> |
public Integer realCompute() { |
195 |
|
int n = number; |
196 |
|
if (n <= 1) |
197 |
|
return n; |
199 |
|
f1.fork(); |
200 |
|
return (new FibTask(n - 2)).compute() + f1.join(); |
201 |
|
} |
202 |
+ |
|
203 |
+ |
public void publicSetRawResult(Integer result) { |
204 |
+ |
setRawResult(result); |
205 |
+ |
} |
206 |
|
} |
207 |
|
|
208 |
|
// A recursive action failing in base case |
209 |
< |
static final class FailingFibTask extends RecursiveTask<Integer> { |
209 |
> |
final class FailingFibTask extends RecursiveTask<Integer> { |
210 |
|
final int number; |
211 |
|
int result; |
212 |
|
FailingFibTask(int n) { number = n; } |
225 |
|
* isCompletedAbnormally and isCancelled return false for normally |
226 |
|
* completed tasks. getRawResult of a completed non-null task |
227 |
|
* returns value; |
68 |
– |
* |
228 |
|
*/ |
229 |
|
public void testInvoke() { |
230 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
231 |
< |
public Integer compute() { |
230 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
231 |
> |
public Integer realCompute() { |
232 |
|
FibTask f = new FibTask(8); |
233 |
|
Integer r = f.invoke(); |
234 |
< |
threadAssertTrue(r == 21); |
235 |
< |
threadAssertTrue(f.isDone()); |
77 |
< |
threadAssertFalse(f.isCancelled()); |
78 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
79 |
< |
threadAssertTrue(f.getRawResult() == 21); |
234 |
> |
assertEquals(21, (int) r); |
235 |
> |
checkCompletedNormally(f, r); |
236 |
|
return r; |
237 |
< |
} |
238 |
< |
}; |
83 |
< |
assertTrue(mainPool.invoke(a) == 21); |
237 |
> |
}}; |
238 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
239 |
|
} |
240 |
|
|
241 |
|
/** |
244 |
|
* completed tasks |
245 |
|
*/ |
246 |
|
public void testQuietlyInvoke() { |
247 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
248 |
< |
public Integer compute() { |
247 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
248 |
> |
public Integer realCompute() { |
249 |
|
FibTask f = new FibTask(8); |
250 |
|
f.quietlyInvoke(); |
251 |
< |
Integer r = f.getRawResult(); |
252 |
< |
threadAssertTrue(r == 21); |
253 |
< |
threadAssertTrue(f.isDone()); |
254 |
< |
threadAssertFalse(f.isCancelled()); |
100 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
101 |
< |
return r; |
102 |
< |
} |
103 |
< |
}; |
104 |
< |
assertTrue(mainPool.invoke(a) == 21); |
251 |
> |
checkCompletedNormally(f, 21); |
252 |
> |
return NoResult; |
253 |
> |
}}; |
254 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
255 |
|
} |
256 |
|
|
257 |
|
/** |
258 |
|
* join of a forked task returns when task completes |
259 |
|
*/ |
260 |
|
public void testForkJoin() { |
261 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
262 |
< |
public Integer compute() { |
261 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
262 |
> |
public Integer realCompute() { |
263 |
|
FibTask f = new FibTask(8); |
264 |
< |
f.fork(); |
264 |
> |
assertSame(f, f.fork()); |
265 |
|
Integer r = f.join(); |
266 |
< |
threadAssertTrue(r == 21); |
267 |
< |
threadAssertTrue(f.isDone()); |
266 |
> |
assertEquals(21, (int) r); |
267 |
> |
checkCompletedNormally(f, r); |
268 |
|
return r; |
269 |
< |
} |
270 |
< |
}; |
121 |
< |
assertTrue(mainPool.invoke(a) == 21); |
269 |
> |
}}; |
270 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
271 |
|
} |
272 |
|
|
273 |
|
/** |
274 |
|
* get of a forked task returns when task completes |
275 |
|
*/ |
276 |
|
public void testForkGet() { |
277 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
278 |
< |
public Integer compute() { |
279 |
< |
try { |
280 |
< |
FibTask f = new FibTask(8); |
281 |
< |
f.fork(); |
282 |
< |
Integer r = f.get(); |
283 |
< |
threadAssertTrue(r == 21); |
284 |
< |
threadAssertTrue(f.isDone()); |
285 |
< |
return r; |
286 |
< |
} catch (Exception ex) { |
138 |
< |
unexpectedException(ex); |
139 |
< |
} |
140 |
< |
return NoResult; |
141 |
< |
} |
142 |
< |
}; |
143 |
< |
assertTrue(mainPool.invoke(a) == 21); |
277 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
278 |
> |
public Integer realCompute() throws Exception { |
279 |
> |
FibTask f = new FibTask(8); |
280 |
> |
assertSame(f, f.fork()); |
281 |
> |
Integer r = f.get(); |
282 |
> |
assertEquals(21, (int) r); |
283 |
> |
checkCompletedNormally(f, r); |
284 |
> |
return r; |
285 |
> |
}}; |
286 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
287 |
|
} |
288 |
|
|
289 |
|
/** |
290 |
|
* timed get of a forked task returns when task completes |
291 |
|
*/ |
292 |
|
public void testForkTimedGet() { |
293 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
294 |
< |
public Integer compute() { |
152 |
< |
try { |
153 |
< |
FibTask f = new FibTask(8); |
154 |
< |
f.fork(); |
155 |
< |
Integer r = f.get(5L, TimeUnit.SECONDS); |
156 |
< |
threadAssertTrue(r == 21); |
157 |
< |
threadAssertTrue(f.isDone()); |
158 |
< |
return r; |
159 |
< |
} catch (Exception ex) { |
160 |
< |
unexpectedException(ex); |
161 |
< |
} |
162 |
< |
return NoResult; |
163 |
< |
} |
164 |
< |
}; |
165 |
< |
assertTrue(mainPool.invoke(a) == 21); |
166 |
< |
} |
167 |
< |
|
168 |
< |
/** |
169 |
< |
* helpJoin of a forked task returns when task completes |
170 |
< |
*/ |
171 |
< |
public void testForkHelpJoin() { |
172 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
173 |
< |
public Integer compute() { |
293 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
294 |
> |
public Integer realCompute() throws Exception { |
295 |
|
FibTask f = new FibTask(8); |
296 |
< |
f.fork(); |
297 |
< |
Integer r = f.helpJoin(); |
298 |
< |
threadAssertTrue(r == 21); |
299 |
< |
threadAssertTrue(f.isDone()); |
296 |
> |
assertSame(f, f.fork()); |
297 |
> |
Integer r = f.get(5L, SECONDS); |
298 |
> |
assertEquals(21, (int) r); |
299 |
> |
checkCompletedNormally(f, r); |
300 |
|
return r; |
301 |
< |
} |
302 |
< |
}; |
182 |
< |
assertTrue(mainPool.invoke(a) == 21); |
301 |
> |
}}; |
302 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
303 |
|
} |
304 |
|
|
305 |
|
/** |
306 |
|
* quietlyJoin of a forked task returns when task completes |
307 |
|
*/ |
308 |
|
public void testForkQuietlyJoin() { |
309 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
310 |
< |
public Integer compute() { |
309 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
310 |
> |
public Integer realCompute() { |
311 |
|
FibTask f = new FibTask(8); |
312 |
< |
f.fork(); |
312 |
> |
assertSame(f, f.fork()); |
313 |
|
f.quietlyJoin(); |
314 |
|
Integer r = f.getRawResult(); |
315 |
< |
threadAssertTrue(r == 21); |
316 |
< |
threadAssertTrue(f.isDone()); |
315 |
> |
assertEquals(21, (int) r); |
316 |
> |
checkCompletedNormally(f, r); |
317 |
|
return r; |
318 |
< |
} |
319 |
< |
}; |
200 |
< |
assertTrue(mainPool.invoke(a) == 21); |
318 |
> |
}}; |
319 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
320 |
|
} |
321 |
|
|
203 |
– |
|
204 |
– |
/** |
205 |
– |
* quietlyHelpJoin of a forked task returns when task completes |
206 |
– |
*/ |
207 |
– |
public void testForkQuietlyHelpJoin() { |
208 |
– |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
209 |
– |
public Integer compute() { |
210 |
– |
FibTask f = new FibTask(8); |
211 |
– |
f.fork(); |
212 |
– |
f.quietlyHelpJoin(); |
213 |
– |
Integer r = f.getRawResult(); |
214 |
– |
threadAssertTrue(r == 21); |
215 |
– |
threadAssertTrue(f.isDone()); |
216 |
– |
return r; |
217 |
– |
} |
218 |
– |
}; |
219 |
– |
assertTrue(mainPool.invoke(a) == 21); |
220 |
– |
} |
221 |
– |
|
222 |
– |
|
322 |
|
/** |
323 |
|
* helpQuiesce returns when tasks are complete. |
324 |
|
* getQueuedTaskCount returns 0 when quiescent |
325 |
|
*/ |
326 |
|
public void testForkHelpQuiesce() { |
327 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
328 |
< |
public Integer compute() { |
327 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
328 |
> |
public Integer realCompute() { |
329 |
|
FibTask f = new FibTask(8); |
330 |
< |
f.fork(); |
331 |
< |
f.helpQuiesce(); |
332 |
< |
Integer r = f.getRawResult(); |
333 |
< |
threadAssertTrue(r == 21); |
334 |
< |
threadAssertTrue(f.isDone()); |
335 |
< |
threadAssertTrue(getQueuedTaskCount() == 0); |
336 |
< |
return r; |
238 |
< |
} |
239 |
< |
}; |
240 |
< |
assertTrue(mainPool.invoke(a) == 21); |
330 |
> |
assertSame(f, f.fork()); |
331 |
> |
helpQuiesce(); |
332 |
> |
assertEquals(0, getQueuedTaskCount()); |
333 |
> |
checkCompletedNormally(f, 21); |
334 |
> |
return NoResult; |
335 |
> |
}}; |
336 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
337 |
|
} |
338 |
|
|
243 |
– |
|
339 |
|
/** |
340 |
|
* invoke task throws exception when task completes abnormally |
341 |
|
*/ |
342 |
|
public void testAbnormalInvoke() { |
343 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
344 |
< |
public Integer compute() { |
343 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
344 |
> |
public Integer realCompute() { |
345 |
> |
FailingFibTask f = new FailingFibTask(8); |
346 |
|
try { |
251 |
– |
FailingFibTask f = new FailingFibTask(8); |
347 |
|
f.invoke(); |
348 |
|
shouldThrow(); |
254 |
– |
return NoResult; |
349 |
|
} catch (FJException success) { |
350 |
+ |
checkCompletedAbnormally(f, success); |
351 |
|
} |
352 |
|
return NoResult; |
353 |
< |
} |
354 |
< |
}; |
260 |
< |
mainPool.invoke(a); |
353 |
> |
}}; |
354 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
355 |
|
} |
356 |
|
|
357 |
|
/** |
358 |
|
* quietlyInvoke task returns when task completes abnormally |
359 |
|
*/ |
360 |
|
public void testAbnormalQuietlyInvoke() { |
361 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
362 |
< |
public Integer compute() { |
361 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
362 |
> |
public Integer realCompute() { |
363 |
|
FailingFibTask f = new FailingFibTask(8); |
364 |
|
f.quietlyInvoke(); |
365 |
< |
threadAssertTrue(f.isDone()); |
365 |
> |
assertTrue(f.getException() instanceof FJException); |
366 |
> |
checkCompletedAbnormally(f, f.getException()); |
367 |
|
return NoResult; |
368 |
< |
} |
369 |
< |
}; |
275 |
< |
mainPool.invoke(a); |
368 |
> |
}}; |
369 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
370 |
|
} |
371 |
|
|
372 |
|
/** |
373 |
|
* join of a forked task throws exception when task completes abnormally |
374 |
|
*/ |
375 |
|
public void testAbnormalForkJoin() { |
376 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
377 |
< |
public Integer compute() { |
376 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
377 |
> |
public Integer realCompute() { |
378 |
> |
FailingFibTask f = new FailingFibTask(8); |
379 |
> |
assertSame(f, f.fork()); |
380 |
|
try { |
285 |
– |
FailingFibTask f = new FailingFibTask(8); |
286 |
– |
f.fork(); |
381 |
|
Integer r = f.join(); |
382 |
|
shouldThrow(); |
289 |
– |
return r; |
383 |
|
} catch (FJException success) { |
384 |
+ |
checkCompletedAbnormally(f, success); |
385 |
|
} |
386 |
|
return NoResult; |
387 |
< |
} |
388 |
< |
}; |
295 |
< |
mainPool.invoke(a); |
387 |
> |
}}; |
388 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
389 |
|
} |
390 |
|
|
391 |
|
/** |
392 |
|
* get of a forked task throws exception when task completes abnormally |
393 |
|
*/ |
394 |
|
public void testAbnormalForkGet() { |
395 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
396 |
< |
public Integer compute() { |
395 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
396 |
> |
public Integer realCompute() throws Exception { |
397 |
> |
FailingFibTask f = new FailingFibTask(8); |
398 |
> |
assertSame(f, f.fork()); |
399 |
|
try { |
305 |
– |
FailingFibTask f = new FailingFibTask(8); |
306 |
– |
f.fork(); |
400 |
|
Integer r = f.get(); |
401 |
|
shouldThrow(); |
309 |
– |
return r; |
402 |
|
} catch (ExecutionException success) { |
403 |
< |
} catch (Exception ex) { |
404 |
< |
unexpectedException(ex); |
403 |
> |
Throwable cause = success.getCause(); |
404 |
> |
assertTrue(cause instanceof FJException); |
405 |
> |
checkCompletedAbnormally(f, cause); |
406 |
|
} |
407 |
|
return NoResult; |
408 |
< |
} |
409 |
< |
}; |
317 |
< |
mainPool.invoke(a); |
408 |
> |
}}; |
409 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
410 |
|
} |
411 |
|
|
412 |
|
/** |
413 |
|
* timed get of a forked task throws exception when task completes abnormally |
414 |
|
*/ |
415 |
|
public void testAbnormalForkTimedGet() { |
416 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
417 |
< |
public Integer compute() { |
416 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
417 |
> |
public Integer realCompute() throws Exception { |
418 |
> |
FailingFibTask f = new FailingFibTask(8); |
419 |
> |
assertSame(f, f.fork()); |
420 |
|
try { |
421 |
< |
FailingFibTask f = new FailingFibTask(8); |
328 |
< |
f.fork(); |
329 |
< |
Integer r = f.get(5L, TimeUnit.SECONDS); |
421 |
> |
Integer r = f.get(5L, SECONDS); |
422 |
|
shouldThrow(); |
331 |
– |
return r; |
423 |
|
} catch (ExecutionException success) { |
424 |
< |
} catch (Exception ex) { |
425 |
< |
unexpectedException(ex); |
424 |
> |
Throwable cause = success.getCause(); |
425 |
> |
assertTrue(cause instanceof FJException); |
426 |
> |
checkCompletedAbnormally(f, cause); |
427 |
|
} |
428 |
|
return NoResult; |
429 |
< |
} |
430 |
< |
}; |
339 |
< |
mainPool.invoke(a); |
340 |
< |
} |
341 |
< |
|
342 |
< |
/** |
343 |
< |
* join of a forked task throws exception when task completes abnormally |
344 |
< |
*/ |
345 |
< |
public void testAbnormalForkHelpJoin() { |
346 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
347 |
< |
public Integer compute() { |
348 |
< |
try { |
349 |
< |
FailingFibTask f = new FailingFibTask(8); |
350 |
< |
f.fork(); |
351 |
< |
Integer r = f.helpJoin(); |
352 |
< |
shouldThrow(); |
353 |
< |
return r; |
354 |
< |
} catch (FJException success) { |
355 |
< |
} |
356 |
< |
return NoResult; |
357 |
< |
} |
358 |
< |
}; |
359 |
< |
mainPool.invoke(a); |
360 |
< |
} |
361 |
< |
|
362 |
< |
/** |
363 |
< |
* quietlyHelpJoin of a forked task returns when task completes abnormally. |
364 |
< |
* getException of failed task returns its exception. |
365 |
< |
* isCompletedAbnormally of a failed task returns true. |
366 |
< |
* isCancelled of a failed uncancelled task returns false |
367 |
< |
*/ |
368 |
< |
public void testAbnormalForkQuietlyHelpJoin() { |
369 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
370 |
< |
public Integer compute() { |
371 |
< |
FailingFibTask f = new FailingFibTask(8); |
372 |
< |
f.fork(); |
373 |
< |
f.quietlyHelpJoin(); |
374 |
< |
threadAssertTrue(f.isDone()); |
375 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
376 |
< |
threadAssertFalse(f.isCancelled()); |
377 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
378 |
< |
return NoResult; |
379 |
< |
} |
380 |
< |
}; |
381 |
< |
mainPool.invoke(a); |
429 |
> |
}}; |
430 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
431 |
|
} |
432 |
|
|
433 |
|
/** |
434 |
|
* quietlyJoin of a forked task returns when task completes abnormally |
435 |
|
*/ |
436 |
|
public void testAbnormalForkQuietlyJoin() { |
437 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
438 |
< |
public Integer compute() { |
437 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
438 |
> |
public Integer realCompute() { |
439 |
|
FailingFibTask f = new FailingFibTask(8); |
440 |
< |
f.fork(); |
440 |
> |
assertSame(f, f.fork()); |
441 |
|
f.quietlyJoin(); |
442 |
< |
threadAssertTrue(f.isDone()); |
443 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
395 |
< |
threadAssertTrue(f.getException() instanceof FJException); |
442 |
> |
assertTrue(f.getException() instanceof FJException); |
443 |
> |
checkCompletedAbnormally(f, f.getException()); |
444 |
|
return NoResult; |
445 |
< |
} |
446 |
< |
}; |
399 |
< |
mainPool.invoke(a); |
445 |
> |
}}; |
446 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
447 |
|
} |
448 |
|
|
449 |
|
/** |
450 |
|
* invoke task throws exception when task cancelled |
451 |
|
*/ |
452 |
|
public void testCancelledInvoke() { |
453 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
454 |
< |
public Integer compute() { |
453 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
454 |
> |
public Integer realCompute() { |
455 |
> |
FibTask f = new FibTask(8); |
456 |
> |
assertTrue(f.cancel(true)); |
457 |
|
try { |
409 |
– |
FibTask f = new FibTask(8); |
410 |
– |
f.cancel(true); |
458 |
|
Integer r = f.invoke(); |
459 |
|
shouldThrow(); |
413 |
– |
return r; |
460 |
|
} catch (CancellationException success) { |
461 |
+ |
checkCancelled(f); |
462 |
|
} |
463 |
|
return NoResult; |
464 |
< |
} |
465 |
< |
}; |
419 |
< |
mainPool.invoke(a); |
464 |
> |
}}; |
465 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
466 |
|
} |
467 |
|
|
468 |
|
/** |
469 |
|
* join of a forked task throws exception when task cancelled |
470 |
|
*/ |
471 |
|
public void testCancelledForkJoin() { |
472 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
473 |
< |
public Integer compute() { |
472 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
473 |
> |
public Integer realCompute() { |
474 |
> |
FibTask f = new FibTask(8); |
475 |
> |
assertTrue(f.cancel(true)); |
476 |
> |
assertSame(f, f.fork()); |
477 |
|
try { |
429 |
– |
FibTask f = new FibTask(8); |
430 |
– |
f.cancel(true); |
431 |
– |
f.fork(); |
478 |
|
Integer r = f.join(); |
479 |
|
shouldThrow(); |
434 |
– |
return r; |
480 |
|
} catch (CancellationException success) { |
481 |
+ |
checkCancelled(f); |
482 |
|
} |
483 |
|
return NoResult; |
484 |
< |
} |
485 |
< |
}; |
440 |
< |
mainPool.invoke(a); |
484 |
> |
}}; |
485 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
486 |
|
} |
487 |
|
|
488 |
|
/** |
489 |
|
* get of a forked task throws exception when task cancelled |
490 |
|
*/ |
491 |
|
public void testCancelledForkGet() { |
492 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
493 |
< |
public Integer compute() { |
492 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
493 |
> |
public Integer realCompute() throws Exception { |
494 |
> |
FibTask f = new FibTask(8); |
495 |
> |
assertTrue(f.cancel(true)); |
496 |
> |
assertSame(f, f.fork()); |
497 |
|
try { |
450 |
– |
FibTask f = new FibTask(8); |
451 |
– |
f.cancel(true); |
452 |
– |
f.fork(); |
498 |
|
Integer r = f.get(); |
499 |
|
shouldThrow(); |
455 |
– |
return r; |
500 |
|
} catch (CancellationException success) { |
501 |
< |
} catch (Exception ex) { |
458 |
< |
unexpectedException(ex); |
501 |
> |
checkCancelled(f); |
502 |
|
} |
503 |
|
return NoResult; |
504 |
< |
} |
505 |
< |
}; |
463 |
< |
mainPool.invoke(a); |
504 |
> |
}}; |
505 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
506 |
|
} |
507 |
|
|
508 |
|
/** |
509 |
|
* timed get of a forked task throws exception when task cancelled |
510 |
|
*/ |
511 |
|
public void testCancelledForkTimedGet() { |
512 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
513 |
< |
public Integer compute() { |
512 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
513 |
> |
public Integer realCompute() throws Exception { |
514 |
> |
FibTask f = new FibTask(8); |
515 |
> |
assertTrue(f.cancel(true)); |
516 |
> |
assertSame(f, f.fork()); |
517 |
|
try { |
518 |
< |
FibTask f = new FibTask(8); |
474 |
< |
f.cancel(true); |
475 |
< |
f.fork(); |
476 |
< |
Integer r = f.get(5L, TimeUnit.SECONDS); |
518 |
> |
Integer r = f.get(5L, SECONDS); |
519 |
|
shouldThrow(); |
478 |
– |
return r; |
520 |
|
} catch (CancellationException success) { |
521 |
< |
} catch (Exception ex) { |
481 |
< |
unexpectedException(ex); |
521 |
> |
checkCancelled(f); |
522 |
|
} |
523 |
|
return NoResult; |
524 |
< |
} |
525 |
< |
}; |
486 |
< |
mainPool.invoke(a); |
487 |
< |
} |
488 |
< |
|
489 |
< |
/** |
490 |
< |
* join of a forked task throws exception when task cancelled |
491 |
< |
*/ |
492 |
< |
public void testCancelledForkHelpJoin() { |
493 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
494 |
< |
public Integer compute() { |
495 |
< |
try { |
496 |
< |
FibTask f = new FibTask(8); |
497 |
< |
f.cancel(true); |
498 |
< |
f.fork(); |
499 |
< |
Integer r = f.helpJoin(); |
500 |
< |
shouldThrow(); |
501 |
< |
return r; |
502 |
< |
} catch (CancellationException success) { |
503 |
< |
} |
504 |
< |
return NoResult; |
505 |
< |
} |
506 |
< |
}; |
507 |
< |
mainPool.invoke(a); |
508 |
< |
} |
509 |
< |
|
510 |
< |
/** |
511 |
< |
* quietlyHelpJoin of a forked task returns when task cancelled. |
512 |
< |
* getException of cancelled task returns its exception |
513 |
< |
* isCompletedAbnormally of a cancelled task returns true. |
514 |
< |
* isCancelled of a cancelled task returns true |
515 |
< |
*/ |
516 |
< |
public void testCancelledForkQuietlyHelpJoin() { |
517 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
518 |
< |
public Integer compute() { |
519 |
< |
FibTask f = new FibTask(8); |
520 |
< |
f.cancel(true); |
521 |
< |
f.fork(); |
522 |
< |
f.quietlyHelpJoin(); |
523 |
< |
threadAssertTrue(f.isDone()); |
524 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
525 |
< |
threadAssertTrue(f.isCancelled()); |
526 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
527 |
< |
return NoResult; |
528 |
< |
} |
529 |
< |
}; |
530 |
< |
mainPool.invoke(a); |
524 |
> |
}}; |
525 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
526 |
|
} |
527 |
|
|
528 |
|
/** |
529 |
|
* quietlyJoin of a forked task returns when task cancelled |
530 |
|
*/ |
531 |
|
public void testCancelledForkQuietlyJoin() { |
532 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
533 |
< |
public Integer compute() { |
532 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
533 |
> |
public Integer realCompute() { |
534 |
|
FibTask f = new FibTask(8); |
535 |
< |
f.cancel(true); |
536 |
< |
f.fork(); |
535 |
> |
assertTrue(f.cancel(true)); |
536 |
> |
assertSame(f, f.fork()); |
537 |
|
f.quietlyJoin(); |
538 |
< |
threadAssertTrue(f.isDone()); |
544 |
< |
threadAssertTrue(f.isCompletedAbnormally()); |
545 |
< |
threadAssertTrue(f.getException() instanceof CancellationException); |
538 |
> |
checkCancelled(f); |
539 |
|
return NoResult; |
540 |
< |
} |
541 |
< |
}; |
549 |
< |
mainPool.invoke(a); |
540 |
> |
}}; |
541 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
542 |
|
} |
543 |
|
|
544 |
|
/** |
545 |
|
* getPool of executing task returns its pool |
546 |
|
*/ |
547 |
|
public void testGetPool() { |
548 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
549 |
< |
public Integer compute() { |
550 |
< |
threadAssertTrue(getPool() == mainPool); |
548 |
> |
final ForkJoinPool mainPool = mainPool(); |
549 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
550 |
> |
public Integer realCompute() { |
551 |
> |
assertSame(mainPool, getPool()); |
552 |
|
return NoResult; |
553 |
< |
} |
554 |
< |
}; |
562 |
< |
mainPool.invoke(a); |
553 |
> |
}}; |
554 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool, a)); |
555 |
|
} |
556 |
|
|
557 |
|
/** |
558 |
|
* getPool of non-FJ task returns null |
559 |
|
*/ |
560 |
|
public void testGetPool2() { |
561 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
562 |
< |
public Integer compute() { |
563 |
< |
threadAssertTrue(getPool() == null); |
561 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
562 |
> |
public Integer realCompute() { |
563 |
> |
assertNull(getPool()); |
564 |
|
return NoResult; |
565 |
< |
} |
566 |
< |
}; |
575 |
< |
a.invoke(); |
565 |
> |
}}; |
566 |
> |
assertSame(NoResult, a.invoke()); |
567 |
|
} |
568 |
|
|
569 |
|
/** |
570 |
|
* inForkJoinPool of executing task returns true |
571 |
|
*/ |
572 |
|
public void testInForkJoinPool() { |
573 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
574 |
< |
public Integer compute() { |
575 |
< |
threadAssertTrue(inForkJoinPool()); |
573 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
574 |
> |
public Integer realCompute() { |
575 |
> |
assertTrue(inForkJoinPool()); |
576 |
|
return NoResult; |
577 |
< |
} |
578 |
< |
}; |
588 |
< |
mainPool.invoke(a); |
577 |
> |
}}; |
578 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
579 |
|
} |
580 |
|
|
581 |
|
/** |
582 |
|
* inForkJoinPool of non-FJ task returns false |
583 |
|
*/ |
584 |
|
public void testInForkJoinPool2() { |
585 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
586 |
< |
public Integer compute() { |
587 |
< |
threadAssertTrue(!inForkJoinPool()); |
585 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
586 |
> |
public Integer realCompute() { |
587 |
> |
assertFalse(inForkJoinPool()); |
588 |
|
return NoResult; |
589 |
< |
} |
590 |
< |
}; |
601 |
< |
a.invoke(); |
589 |
> |
}}; |
590 |
> |
assertSame(NoResult, a.invoke()); |
591 |
|
} |
592 |
|
|
593 |
|
/** |
594 |
< |
* setRawResult(null) succeeds |
594 |
> |
* The value set by setRawResult is returned by getRawResult |
595 |
|
*/ |
596 |
|
public void testSetRawResult() { |
597 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
598 |
< |
public Integer compute() { |
597 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
598 |
> |
public Integer realCompute() { |
599 |
|
setRawResult(NoResult); |
600 |
+ |
assertSame(NoResult, getRawResult()); |
601 |
|
return NoResult; |
602 |
|
} |
603 |
|
}; |
604 |
< |
assertEquals(a.invoke(), NoResult); |
604 |
> |
assertSame(NoResult, a.invoke()); |
605 |
|
} |
606 |
|
|
607 |
|
/** |
608 |
< |
* A reinitialized task may be re-invoked |
608 |
> |
* A reinitialized normally completed task may be re-invoked |
609 |
|
*/ |
610 |
|
public void testReinitialize() { |
611 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
612 |
< |
public Integer compute() { |
611 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
612 |
> |
public Integer realCompute() { |
613 |
|
FibTask f = new FibTask(8); |
614 |
< |
Integer r = f.invoke(); |
615 |
< |
threadAssertTrue(r == 21); |
616 |
< |
threadAssertTrue(f.isDone()); |
617 |
< |
threadAssertFalse(f.isCancelled()); |
618 |
< |
threadAssertFalse(f.isCompletedAbnormally()); |
619 |
< |
f.reinitialize(); |
620 |
< |
r = f.invoke(); |
621 |
< |
threadAssertTrue(r == 21); |
614 |
> |
checkNotDone(f); |
615 |
> |
|
616 |
> |
for (int i = 0; i < 3; i++) { |
617 |
> |
Integer r = f.invoke(); |
618 |
> |
assertEquals(21, (int) r); |
619 |
> |
checkCompletedNormally(f, r); |
620 |
> |
f.reinitialize(); |
621 |
> |
f.publicSetRawResult(null); |
622 |
> |
checkNotDone(f); |
623 |
> |
} |
624 |
|
return NoResult; |
625 |
< |
} |
626 |
< |
}; |
627 |
< |
mainPool.invoke(a); |
625 |
> |
}}; |
626 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
627 |
> |
} |
628 |
> |
|
629 |
> |
/** |
630 |
> |
* A reinitialized abnormally completed task may be re-invoked |
631 |
> |
*/ |
632 |
> |
public void testReinitializeAbnormal() { |
633 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
634 |
> |
public Integer realCompute() { |
635 |
> |
FailingFibTask f = new FailingFibTask(8); |
636 |
> |
checkNotDone(f); |
637 |
> |
|
638 |
> |
for (int i = 0; i < 3; i++) { |
639 |
> |
try { |
640 |
> |
f.invoke(); |
641 |
> |
shouldThrow(); |
642 |
> |
} catch (FJException success) { |
643 |
> |
checkCompletedAbnormally(f, success); |
644 |
> |
} |
645 |
> |
f.reinitialize(); |
646 |
> |
checkNotDone(f); |
647 |
> |
} |
648 |
> |
return NoResult; |
649 |
> |
}}; |
650 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
651 |
|
} |
652 |
|
|
653 |
|
/** |
654 |
|
* invoke task throws exception after invoking completeExceptionally |
655 |
|
*/ |
656 |
|
public void testCompleteExceptionally() { |
657 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
658 |
< |
public Integer compute() { |
657 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
658 |
> |
public Integer realCompute() { |
659 |
> |
FibTask f = new FibTask(8); |
660 |
> |
f.completeExceptionally(new FJException()); |
661 |
|
try { |
645 |
– |
FibTask f = new FibTask(8); |
646 |
– |
f.completeExceptionally(new FJException()); |
662 |
|
Integer r = f.invoke(); |
663 |
|
shouldThrow(); |
649 |
– |
return r; |
664 |
|
} catch (FJException success) { |
665 |
+ |
checkCompletedAbnormally(f, success); |
666 |
|
} |
667 |
|
return NoResult; |
668 |
< |
} |
669 |
< |
}; |
655 |
< |
mainPool.invoke(a); |
668 |
> |
}}; |
669 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
670 |
|
} |
671 |
|
|
672 |
|
/** |
673 |
|
* invoke task suppresses execution invoking complete |
674 |
|
*/ |
675 |
|
public void testComplete() { |
676 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
677 |
< |
public Integer compute() { |
676 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
677 |
> |
public Integer realCompute() { |
678 |
|
FibTask f = new FibTask(8); |
679 |
|
f.complete(NoResult); |
680 |
|
Integer r = f.invoke(); |
681 |
< |
threadAssertTrue(f.isDone()); |
682 |
< |
threadAssertTrue(r == NoResult); |
681 |
> |
assertSame(NoResult, r); |
682 |
> |
checkCompletedNormally(f, NoResult); |
683 |
|
return r; |
684 |
< |
} |
685 |
< |
}; |
672 |
< |
mainPool.invoke(a); |
684 |
> |
}}; |
685 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
686 |
|
} |
687 |
|
|
688 |
|
/** |
689 |
|
* invokeAll(t1, t2) invokes all task arguments |
690 |
|
*/ |
691 |
|
public void testInvokeAll2() { |
692 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
693 |
< |
public Integer compute() { |
692 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
693 |
> |
public Integer realCompute() { |
694 |
|
FibTask f = new FibTask(8); |
695 |
|
FibTask g = new FibTask(9); |
696 |
|
invokeAll(f, g); |
697 |
< |
threadAssertTrue(f.isDone()); |
698 |
< |
threadAssertTrue(f.join() == 21); |
686 |
< |
threadAssertTrue(g.isDone()); |
687 |
< |
threadAssertTrue(g.join() == 34); |
697 |
> |
checkCompletedNormally(f, 21); |
698 |
> |
checkCompletedNormally(g, 34); |
699 |
|
return NoResult; |
700 |
< |
} |
701 |
< |
}; |
691 |
< |
mainPool.invoke(a); |
700 |
> |
}}; |
701 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
702 |
|
} |
703 |
|
|
704 |
|
/** |
705 |
|
* invokeAll(tasks) with 1 argument invokes task |
706 |
|
*/ |
707 |
|
public void testInvokeAll1() { |
708 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
709 |
< |
public Integer compute() { |
708 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
709 |
> |
public Integer realCompute() { |
710 |
|
FibTask f = new FibTask(8); |
711 |
|
invokeAll(f); |
712 |
< |
threadAssertTrue(f.isDone()); |
703 |
< |
threadAssertTrue(f.join() == 21); |
712 |
> |
checkCompletedNormally(f, 21); |
713 |
|
return NoResult; |
714 |
< |
} |
715 |
< |
}; |
707 |
< |
mainPool.invoke(a); |
714 |
> |
}}; |
715 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
716 |
|
} |
717 |
|
|
718 |
|
/** |
719 |
|
* invokeAll(tasks) with > 2 argument invokes tasks |
720 |
|
*/ |
721 |
|
public void testInvokeAll3() { |
722 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
723 |
< |
public Integer compute() { |
722 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
723 |
> |
public Integer realCompute() { |
724 |
|
FibTask f = new FibTask(8); |
725 |
|
FibTask g = new FibTask(9); |
726 |
|
FibTask h = new FibTask(7); |
727 |
|
invokeAll(f, g, h); |
728 |
< |
threadAssertTrue(f.isDone()); |
729 |
< |
threadAssertTrue(f.join() == 21); |
730 |
< |
threadAssertTrue(g.isDone()); |
731 |
< |
threadAssertTrue(g.join() == 34); |
732 |
< |
threadAssertTrue(h.isDone()); |
733 |
< |
threadAssertTrue(h.join() == 13); |
728 |
> |
assertTrue(f.isDone()); |
729 |
> |
assertTrue(g.isDone()); |
730 |
> |
assertTrue(h.isDone()); |
731 |
> |
checkCompletedNormally(f, 21); |
732 |
> |
checkCompletedNormally(g, 34); |
733 |
> |
checkCompletedNormally(h, 13); |
734 |
|
return NoResult; |
735 |
< |
} |
736 |
< |
}; |
729 |
< |
mainPool.invoke(a); |
735 |
> |
}}; |
736 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
737 |
|
} |
738 |
|
|
739 |
|
/** |
740 |
|
* invokeAll(collection) invokes all tasks in the collection |
741 |
|
*/ |
742 |
|
public void testInvokeAllCollection() { |
743 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
744 |
< |
public Integer compute() { |
743 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
744 |
> |
public Integer realCompute() { |
745 |
|
FibTask f = new FibTask(8); |
746 |
|
FibTask g = new FibTask(9); |
747 |
|
FibTask h = new FibTask(7); |
750 |
|
set.add(g); |
751 |
|
set.add(h); |
752 |
|
invokeAll(set); |
753 |
< |
threadAssertTrue(f.isDone()); |
754 |
< |
threadAssertTrue(f.join() == 21); |
755 |
< |
threadAssertTrue(g.isDone()); |
756 |
< |
threadAssertTrue(g.join() == 34); |
757 |
< |
threadAssertTrue(h.isDone()); |
758 |
< |
threadAssertTrue(h.join() == 13); |
753 |
> |
assertTrue(f.isDone()); |
754 |
> |
assertTrue(g.isDone()); |
755 |
> |
assertTrue(h.isDone()); |
756 |
> |
checkCompletedNormally(f, 21); |
757 |
> |
checkCompletedNormally(g, 34); |
758 |
> |
checkCompletedNormally(h, 13); |
759 |
|
return NoResult; |
760 |
< |
} |
761 |
< |
}; |
755 |
< |
mainPool.invoke(a); |
760 |
> |
}}; |
761 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
762 |
|
} |
763 |
|
|
764 |
+ |
/** |
765 |
+ |
* invokeAll(tasks) with any null task throws NPE |
766 |
+ |
*/ |
767 |
+ |
public void testInvokeAllNPE() { |
768 |
+ |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
769 |
+ |
public Integer realCompute() { |
770 |
+ |
FibTask f = new FibTask(8); |
771 |
+ |
FibTask g = new FibTask(9); |
772 |
+ |
FibTask h = null; |
773 |
+ |
try { |
774 |
+ |
invokeAll(f, g, h); |
775 |
+ |
shouldThrow(); |
776 |
+ |
} catch (NullPointerException success) {} |
777 |
+ |
return NoResult; |
778 |
+ |
}}; |
779 |
+ |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
780 |
+ |
} |
781 |
|
|
782 |
|
/** |
783 |
|
* invokeAll(t1, t2) throw exception if any task does |
784 |
|
*/ |
785 |
|
public void testAbnormalInvokeAll2() { |
786 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
787 |
< |
public Integer compute() { |
786 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
787 |
> |
public Integer realCompute() { |
788 |
> |
FibTask f = new FibTask(8); |
789 |
> |
FailingFibTask g = new FailingFibTask(9); |
790 |
|
try { |
766 |
– |
FibTask f = new FibTask(8); |
767 |
– |
FailingFibTask g = new FailingFibTask(9); |
791 |
|
invokeAll(f, g); |
792 |
|
shouldThrow(); |
770 |
– |
return NoResult; |
793 |
|
} catch (FJException success) { |
794 |
+ |
checkCompletedAbnormally(g, success); |
795 |
|
} |
796 |
|
return NoResult; |
797 |
< |
} |
798 |
< |
}; |
776 |
< |
mainPool.invoke(a); |
797 |
> |
}}; |
798 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
799 |
|
} |
800 |
|
|
801 |
|
/** |
802 |
|
* invokeAll(tasks) with 1 argument throws exception if task does |
803 |
|
*/ |
804 |
|
public void testAbnormalInvokeAll1() { |
805 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
806 |
< |
public Integer compute() { |
805 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
806 |
> |
public Integer realCompute() { |
807 |
> |
FailingFibTask g = new FailingFibTask(9); |
808 |
|
try { |
786 |
– |
FailingFibTask g = new FailingFibTask(9); |
809 |
|
invokeAll(g); |
810 |
|
shouldThrow(); |
789 |
– |
return NoResult; |
811 |
|
} catch (FJException success) { |
812 |
+ |
checkCompletedAbnormally(g, success); |
813 |
|
} |
814 |
|
return NoResult; |
815 |
< |
} |
816 |
< |
}; |
795 |
< |
mainPool.invoke(a); |
815 |
> |
}}; |
816 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
817 |
|
} |
818 |
|
|
819 |
|
/** |
820 |
|
* invokeAll(tasks) with > 2 argument throws exception if any task does |
821 |
|
*/ |
822 |
|
public void testAbnormalInvokeAll3() { |
823 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
824 |
< |
public Integer compute() { |
823 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
824 |
> |
public Integer realCompute() { |
825 |
> |
FibTask f = new FibTask(8); |
826 |
> |
FailingFibTask g = new FailingFibTask(9); |
827 |
> |
FibTask h = new FibTask(7); |
828 |
|
try { |
805 |
– |
FibTask f = new FibTask(8); |
806 |
– |
FailingFibTask g = new FailingFibTask(9); |
807 |
– |
FibTask h = new FibTask(7); |
829 |
|
invokeAll(f, g, h); |
830 |
|
shouldThrow(); |
810 |
– |
return NoResult; |
831 |
|
} catch (FJException success) { |
832 |
+ |
checkCompletedAbnormally(g, success); |
833 |
|
} |
834 |
|
return NoResult; |
835 |
< |
} |
836 |
< |
}; |
816 |
< |
mainPool.invoke(a); |
835 |
> |
}}; |
836 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
837 |
|
} |
838 |
|
|
839 |
|
/** |
840 |
|
* invokeAll(collection) throws exception if any task does |
841 |
|
*/ |
842 |
|
public void testAbnormalInvokeAllCollection() { |
843 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
844 |
< |
public Integer compute() { |
843 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
844 |
> |
public Integer realCompute() { |
845 |
> |
FailingFibTask f = new FailingFibTask(8); |
846 |
> |
FibTask g = new FibTask(9); |
847 |
> |
FibTask h = new FibTask(7); |
848 |
> |
HashSet set = new HashSet(); |
849 |
> |
set.add(f); |
850 |
> |
set.add(g); |
851 |
> |
set.add(h); |
852 |
|
try { |
826 |
– |
FailingFibTask f = new FailingFibTask(8); |
827 |
– |
FibTask g = new FibTask(9); |
828 |
– |
FibTask h = new FibTask(7); |
829 |
– |
HashSet set = new HashSet(); |
830 |
– |
set.add(f); |
831 |
– |
set.add(g); |
832 |
– |
set.add(h); |
853 |
|
invokeAll(set); |
854 |
|
shouldThrow(); |
835 |
– |
return NoResult; |
855 |
|
} catch (FJException success) { |
856 |
+ |
checkCompletedAbnormally(f, success); |
857 |
|
} |
858 |
|
return NoResult; |
859 |
< |
} |
860 |
< |
}; |
841 |
< |
mainPool.invoke(a); |
859 |
> |
}}; |
860 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
861 |
|
} |
862 |
|
|
863 |
|
/** |
865 |
|
* and suppresses execution |
866 |
|
*/ |
867 |
|
public void testTryUnfork() { |
868 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
869 |
< |
public Integer compute() { |
868 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
869 |
> |
public Integer realCompute() { |
870 |
|
FibTask g = new FibTask(9); |
871 |
< |
g.fork(); |
871 |
> |
assertSame(g, g.fork()); |
872 |
|
FibTask f = new FibTask(8); |
873 |
< |
f.fork(); |
874 |
< |
threadAssertTrue(f.tryUnfork()); |
873 |
> |
assertSame(f, f.fork()); |
874 |
> |
assertTrue(f.tryUnfork()); |
875 |
|
helpQuiesce(); |
876 |
< |
threadAssertFalse(f.isDone()); |
877 |
< |
threadAssertTrue(g.isDone()); |
876 |
> |
checkNotDone(f); |
877 |
> |
checkCompletedNormally(g, 34); |
878 |
|
return NoResult; |
879 |
< |
} |
880 |
< |
}; |
862 |
< |
singletonPool.invoke(a); |
879 |
> |
}}; |
880 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
881 |
|
} |
882 |
|
|
883 |
|
/** |
885 |
|
* there are more tasks than threads |
886 |
|
*/ |
887 |
|
public void testGetSurplusQueuedTaskCount() { |
888 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
889 |
< |
public Integer compute() { |
888 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
889 |
> |
public Integer realCompute() { |
890 |
|
FibTask h = new FibTask(7); |
891 |
< |
h.fork(); |
891 |
> |
assertSame(h, h.fork()); |
892 |
|
FibTask g = new FibTask(9); |
893 |
< |
g.fork(); |
893 |
> |
assertSame(g, g.fork()); |
894 |
|
FibTask f = new FibTask(8); |
895 |
< |
f.fork(); |
896 |
< |
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
895 |
> |
assertSame(f, f.fork()); |
896 |
> |
assertTrue(getSurplusQueuedTaskCount() > 0); |
897 |
|
helpQuiesce(); |
898 |
+ |
assertEquals(0, getSurplusQueuedTaskCount()); |
899 |
+ |
checkCompletedNormally(f, 21); |
900 |
+ |
checkCompletedNormally(g, 34); |
901 |
+ |
checkCompletedNormally(h, 13); |
902 |
|
return NoResult; |
903 |
< |
} |
904 |
< |
}; |
883 |
< |
singletonPool.invoke(a); |
903 |
> |
}}; |
904 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
905 |
|
} |
906 |
|
|
907 |
|
/** |
908 |
|
* peekNextLocalTask returns most recent unexecuted task. |
909 |
|
*/ |
910 |
|
public void testPeekNextLocalTask() { |
911 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
912 |
< |
public Integer compute() { |
911 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
912 |
> |
public Integer realCompute() { |
913 |
|
FibTask g = new FibTask(9); |
914 |
< |
g.fork(); |
914 |
> |
assertSame(g, g.fork()); |
915 |
|
FibTask f = new FibTask(8); |
916 |
< |
f.fork(); |
917 |
< |
threadAssertTrue(peekNextLocalTask() == f); |
918 |
< |
f.join(); |
898 |
< |
threadAssertTrue(f.isDone()); |
916 |
> |
assertSame(f, f.fork()); |
917 |
> |
assertSame(f, peekNextLocalTask()); |
918 |
> |
checkCompletesNormally(f, 21); |
919 |
|
helpQuiesce(); |
920 |
+ |
checkCompletedNormally(g, 34); |
921 |
|
return NoResult; |
922 |
< |
} |
923 |
< |
}; |
903 |
< |
singletonPool.invoke(a); |
922 |
> |
}}; |
923 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
924 |
|
} |
925 |
|
|
926 |
|
/** |
928 |
|
* without executing it |
929 |
|
*/ |
930 |
|
public void testPollNextLocalTask() { |
931 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
932 |
< |
public Integer compute() { |
931 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
932 |
> |
public Integer realCompute() { |
933 |
|
FibTask g = new FibTask(9); |
934 |
< |
g.fork(); |
934 |
> |
assertSame(g, g.fork()); |
935 |
|
FibTask f = new FibTask(8); |
936 |
< |
f.fork(); |
937 |
< |
threadAssertTrue(pollNextLocalTask() == f); |
936 |
> |
assertSame(f, f.fork()); |
937 |
> |
assertSame(f, pollNextLocalTask()); |
938 |
|
helpQuiesce(); |
939 |
< |
threadAssertFalse(f.isDone()); |
939 |
> |
checkNotDone(f); |
940 |
> |
checkCompletedNormally(g, 34); |
941 |
|
return NoResult; |
942 |
< |
} |
943 |
< |
}; |
923 |
< |
singletonPool.invoke(a); |
942 |
> |
}}; |
943 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
944 |
|
} |
945 |
|
|
946 |
|
/** |
947 |
< |
* pollTask returns an unexecuted task |
928 |
< |
* without executing it |
947 |
> |
* pollTask returns an unexecuted task without executing it |
948 |
|
*/ |
949 |
|
public void testPollTask() { |
950 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
951 |
< |
public Integer compute() { |
950 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
951 |
> |
public Integer realCompute() { |
952 |
|
FibTask g = new FibTask(9); |
953 |
< |
g.fork(); |
953 |
> |
assertSame(g, g.fork()); |
954 |
|
FibTask f = new FibTask(8); |
955 |
< |
f.fork(); |
956 |
< |
threadAssertTrue(pollTask() == f); |
955 |
> |
assertSame(f, f.fork()); |
956 |
> |
assertSame(f, pollTask()); |
957 |
|
helpQuiesce(); |
958 |
< |
threadAssertFalse(f.isDone()); |
959 |
< |
threadAssertTrue(g.isDone()); |
958 |
> |
checkNotDone(f); |
959 |
> |
checkCompletedNormally(g, 34); |
960 |
|
return NoResult; |
961 |
< |
} |
962 |
< |
}; |
944 |
< |
singletonPool.invoke(a); |
961 |
> |
}}; |
962 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
963 |
|
} |
964 |
|
|
965 |
|
/** |
966 |
|
* peekNextLocalTask returns least recent unexecuted task in async mode |
967 |
|
*/ |
968 |
|
public void testPeekNextLocalTaskAsync() { |
969 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
970 |
< |
public Integer compute() { |
969 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
970 |
> |
public Integer realCompute() { |
971 |
|
FibTask g = new FibTask(9); |
972 |
< |
g.fork(); |
972 |
> |
assertSame(g, g.fork()); |
973 |
|
FibTask f = new FibTask(8); |
974 |
< |
f.fork(); |
975 |
< |
threadAssertTrue(peekNextLocalTask() == g); |
976 |
< |
f.join(); |
974 |
> |
assertSame(f, f.fork()); |
975 |
> |
assertSame(g, peekNextLocalTask()); |
976 |
> |
assertEquals(21, (int) f.join()); |
977 |
|
helpQuiesce(); |
978 |
< |
threadAssertTrue(f.isDone()); |
978 |
> |
checkCompletedNormally(f, 21); |
979 |
> |
checkCompletedNormally(g, 34); |
980 |
|
return NoResult; |
981 |
< |
} |
982 |
< |
}; |
964 |
< |
asyncSingletonPool.invoke(a); |
981 |
> |
}}; |
982 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
983 |
|
} |
984 |
|
|
985 |
|
/** |
986 |
< |
* pollNextLocalTask returns least recent unexecuted task |
987 |
< |
* without executing it, in async mode |
986 |
> |
* pollNextLocalTask returns least recent unexecuted task without |
987 |
> |
* executing it, in async mode |
988 |
|
*/ |
989 |
|
public void testPollNextLocalTaskAsync() { |
990 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
991 |
< |
public Integer compute() { |
990 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
991 |
> |
public Integer realCompute() { |
992 |
|
FibTask g = new FibTask(9); |
993 |
< |
g.fork(); |
993 |
> |
assertSame(g, g.fork()); |
994 |
|
FibTask f = new FibTask(8); |
995 |
< |
f.fork(); |
996 |
< |
threadAssertTrue(pollNextLocalTask() == g); |
995 |
> |
assertSame(f, f.fork()); |
996 |
> |
assertSame(g, pollNextLocalTask()); |
997 |
|
helpQuiesce(); |
998 |
< |
threadAssertTrue(f.isDone()); |
999 |
< |
threadAssertFalse(g.isDone()); |
998 |
> |
checkCompletedNormally(f, 21); |
999 |
> |
checkNotDone(g); |
1000 |
|
return NoResult; |
1001 |
< |
} |
1002 |
< |
}; |
985 |
< |
asyncSingletonPool.invoke(a); |
1001 |
> |
}}; |
1002 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
1003 |
|
} |
1004 |
|
|
1005 |
|
/** |
1006 |
< |
* pollTask returns an unexecuted task |
1007 |
< |
* without executing it, in async mode |
1006 |
> |
* pollTask returns an unexecuted task without executing it, in |
1007 |
> |
* async mode |
1008 |
|
*/ |
1009 |
|
public void testPollTaskAsync() { |
1010 |
< |
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
1011 |
< |
public Integer compute() { |
1010 |
> |
RecursiveTask<Integer> a = new CheckedRecursiveTask<Integer>() { |
1011 |
> |
public Integer realCompute() { |
1012 |
|
FibTask g = new FibTask(9); |
1013 |
< |
g.fork(); |
1013 |
> |
assertSame(g, g.fork()); |
1014 |
|
FibTask f = new FibTask(8); |
1015 |
< |
f.fork(); |
1016 |
< |
threadAssertTrue(pollTask() == g); |
1015 |
> |
assertSame(f, f.fork()); |
1016 |
> |
assertSame(g, pollTask()); |
1017 |
|
helpQuiesce(); |
1018 |
< |
threadAssertTrue(f.isDone()); |
1019 |
< |
threadAssertFalse(g.isDone()); |
1018 |
> |
checkCompletedNormally(f, 21); |
1019 |
> |
checkNotDone(g); |
1020 |
|
return NoResult; |
1021 |
< |
} |
1022 |
< |
}; |
1006 |
< |
asyncSingletonPool.invoke(a); |
1021 |
> |
}}; |
1022 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
1023 |
|
} |
1024 |
|
|
1025 |
|
} |