1 |
dl |
1.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 |
5 |
|
|
*/ |
6 |
jsr166 |
1.14 |
|
7 |
dl |
1.1 |
import junit.framework.*; |
8 |
jsr166 |
1.15 |
import java.util.concurrent.CancellationException; |
9 |
|
|
import java.util.concurrent.ExecutionException; |
10 |
|
|
import java.util.concurrent.ForkJoinPool; |
11 |
|
|
import java.util.concurrent.ForkJoinWorkerThread; |
12 |
|
|
import java.util.concurrent.RecursiveAction; |
13 |
|
|
import java.util.concurrent.TimeUnit; |
14 |
|
|
import java.util.HashSet; |
15 |
dl |
1.1 |
|
16 |
|
|
public class RecursiveActionTest extends JSR166TestCase { |
17 |
|
|
|
18 |
|
|
public static void main(String[] args) { |
19 |
jsr166 |
1.11 |
junit.textui.TestRunner.run(suite()); |
20 |
dl |
1.1 |
} |
21 |
jsr166 |
1.13 |
|
22 |
dl |
1.1 |
public static Test suite() { |
23 |
jsr166 |
1.9 |
return new TestSuite(RecursiveActionTest.class); |
24 |
dl |
1.1 |
} |
25 |
|
|
|
26 |
jsr166 |
1.14 |
private static ForkJoinPool mainPool() { |
27 |
|
|
return new ForkJoinPool(); |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
private static ForkJoinPool singletonPool() { |
31 |
|
|
return new ForkJoinPool(1); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
private static ForkJoinPool asyncSingletonPool() { |
35 |
|
|
return new ForkJoinPool(1, |
36 |
|
|
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
37 |
|
|
null, true); |
38 |
|
|
} |
39 |
|
|
|
40 |
|
|
private void testInvokeOnPool(ForkJoinPool pool, RecursiveAction a) { |
41 |
|
|
try { |
42 |
jsr166 |
1.18 |
assertFalse(a.isDone()); |
43 |
|
|
assertFalse(a.isCompletedNormally()); |
44 |
|
|
assertFalse(a.isCompletedAbnormally()); |
45 |
|
|
assertFalse(a.isCancelled()); |
46 |
|
|
assertNull(a.getException()); |
47 |
|
|
|
48 |
|
|
assertNull(pool.invoke(a)); |
49 |
|
|
|
50 |
|
|
assertTrue(a.isDone()); |
51 |
|
|
assertTrue(a.isCompletedNormally()); |
52 |
|
|
assertFalse(a.isCompletedAbnormally()); |
53 |
|
|
assertFalse(a.isCancelled()); |
54 |
|
|
assertNull(a.getException()); |
55 |
jsr166 |
1.14 |
} finally { |
56 |
|
|
joinPool(pool); |
57 |
|
|
} |
58 |
|
|
} |
59 |
dl |
1.1 |
|
60 |
|
|
static final class FJException extends RuntimeException { |
61 |
|
|
FJException() { super(); } |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
// A simple recursive action for testing |
65 |
jsr166 |
1.18 |
final class FibAction extends CheckedRecursiveAction { |
66 |
dl |
1.1 |
final int number; |
67 |
|
|
int result; |
68 |
|
|
FibAction(int n) { number = n; } |
69 |
jsr166 |
1.18 |
public void realCompute() { |
70 |
dl |
1.1 |
int n = number; |
71 |
|
|
if (n <= 1) |
72 |
|
|
result = n; |
73 |
|
|
else { |
74 |
|
|
FibAction f1 = new FibAction(n - 1); |
75 |
|
|
FibAction f2 = new FibAction(n - 2); |
76 |
|
|
invokeAll(f1, f2); |
77 |
|
|
result = f1.result + f2.result; |
78 |
|
|
} |
79 |
|
|
} |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
// A recursive action failing in base case |
83 |
jsr166 |
1.2 |
static final class FailingFibAction extends RecursiveAction { |
84 |
dl |
1.1 |
final int number; |
85 |
|
|
int result; |
86 |
|
|
FailingFibAction(int n) { number = n; } |
87 |
|
|
public void compute() { |
88 |
|
|
int n = number; |
89 |
|
|
if (n <= 1) |
90 |
|
|
throw new FJException(); |
91 |
|
|
else { |
92 |
|
|
FailingFibAction f1 = new FailingFibAction(n - 1); |
93 |
|
|
FailingFibAction f2 = new FailingFibAction(n - 2); |
94 |
|
|
invokeAll(f1, f2); |
95 |
|
|
result = f1.result + f2.result; |
96 |
|
|
} |
97 |
|
|
} |
98 |
|
|
} |
99 |
|
|
|
100 |
jsr166 |
1.2 |
/** |
101 |
dl |
1.1 |
* invoke returns when task completes normally. |
102 |
|
|
* isCompletedAbnormally and isCancelled return false for normally |
103 |
|
|
* completed tasks. getRawResult of a RecursiveAction returns null; |
104 |
|
|
*/ |
105 |
|
|
public void testInvoke() { |
106 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
107 |
|
|
public void realCompute() { |
108 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
109 |
jsr166 |
1.18 |
assertNull(f.invoke()); |
110 |
|
|
assertEquals(21, f.result); |
111 |
|
|
assertTrue(f.isDone()); |
112 |
|
|
assertFalse(f.isCancelled()); |
113 |
|
|
assertFalse(f.isCompletedAbnormally()); |
114 |
|
|
assertNull(f.getRawResult()); |
115 |
jsr166 |
1.7 |
}}; |
116 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
117 |
dl |
1.1 |
} |
118 |
|
|
|
119 |
jsr166 |
1.2 |
/** |
120 |
dl |
1.1 |
* quietlyInvoke task returns when task completes normally. |
121 |
|
|
* isCompletedAbnormally and isCancelled return false for normally |
122 |
|
|
* completed tasks |
123 |
|
|
*/ |
124 |
|
|
public void testQuietlyInvoke() { |
125 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
126 |
|
|
public void realCompute() { |
127 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
128 |
|
|
f.quietlyInvoke(); |
129 |
jsr166 |
1.18 |
assertEquals(21, f.result); |
130 |
|
|
assertTrue(f.isDone()); |
131 |
|
|
assertFalse(f.isCancelled()); |
132 |
|
|
assertFalse(f.isCompletedAbnormally()); |
133 |
|
|
assertNull(f.getRawResult()); |
134 |
jsr166 |
1.7 |
}}; |
135 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
136 |
dl |
1.1 |
} |
137 |
|
|
|
138 |
jsr166 |
1.2 |
/** |
139 |
dl |
1.1 |
* join of a forked task returns when task completes |
140 |
|
|
*/ |
141 |
|
|
public void testForkJoin() { |
142 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
143 |
|
|
public void realCompute() { |
144 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
145 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
146 |
|
|
assertNull(f.join()); |
147 |
|
|
assertEquals(21, f.result); |
148 |
|
|
assertTrue(f.isDone()); |
149 |
|
|
assertNull(f.getRawResult()); |
150 |
jsr166 |
1.7 |
}}; |
151 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
152 |
dl |
1.1 |
} |
153 |
|
|
|
154 |
jsr166 |
1.2 |
/** |
155 |
dl |
1.1 |
* get of a forked task returns when task completes |
156 |
|
|
*/ |
157 |
|
|
public void testForkGet() { |
158 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
159 |
|
|
public void realCompute() throws Exception { |
160 |
|
|
FibAction f = new FibAction(8); |
161 |
|
|
assertSame(f, f.fork()); |
162 |
|
|
assertNull(f.get()); |
163 |
|
|
assertEquals(21, f.result); |
164 |
|
|
assertTrue(f.isDone()); |
165 |
jsr166 |
1.7 |
}}; |
166 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
167 |
dl |
1.1 |
} |
168 |
|
|
|
169 |
jsr166 |
1.2 |
/** |
170 |
dl |
1.1 |
* timed get of a forked task returns when task completes |
171 |
|
|
*/ |
172 |
|
|
public void testForkTimedGet() { |
173 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
174 |
|
|
public void realCompute() throws Exception { |
175 |
|
|
FibAction f = new FibAction(8); |
176 |
|
|
assertSame(f, f.fork()); |
177 |
|
|
assertNull(f.get(5L, TimeUnit.SECONDS)); |
178 |
|
|
assertEquals(21, f.result); |
179 |
|
|
assertTrue(f.isDone()); |
180 |
jsr166 |
1.7 |
}}; |
181 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
182 |
dl |
1.1 |
} |
183 |
|
|
|
184 |
jsr166 |
1.2 |
/** |
185 |
dl |
1.1 |
* timed get with null time unit throws NPE |
186 |
|
|
*/ |
187 |
|
|
public void testForkTimedGetNPE() { |
188 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
189 |
|
|
public void realCompute() throws Exception { |
190 |
|
|
FibAction f = new FibAction(8); |
191 |
|
|
assertSame(f, f.fork()); |
192 |
jsr166 |
1.8 |
try { |
193 |
|
|
f.get(5L, null); |
194 |
|
|
shouldThrow(); |
195 |
jsr166 |
1.18 |
} catch (NullPointerException success) {} |
196 |
jsr166 |
1.8 |
}}; |
197 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
198 |
dl |
1.1 |
} |
199 |
|
|
|
200 |
jsr166 |
1.2 |
/** |
201 |
dl |
1.1 |
* quietlyJoin of a forked task returns when task completes |
202 |
|
|
*/ |
203 |
|
|
public void testForkQuietlyJoin() { |
204 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
205 |
|
|
public void realCompute() { |
206 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
207 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
208 |
jsr166 |
1.7 |
f.quietlyJoin(); |
209 |
jsr166 |
1.18 |
assertEquals(21, f.result); |
210 |
|
|
assertTrue(f.isDone()); |
211 |
jsr166 |
1.7 |
}}; |
212 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
213 |
dl |
1.1 |
} |
214 |
|
|
|
215 |
|
|
|
216 |
jsr166 |
1.2 |
/** |
217 |
dl |
1.1 |
* helpQuiesce returns when tasks are complete. |
218 |
|
|
* getQueuedTaskCount returns 0 when quiescent |
219 |
|
|
*/ |
220 |
|
|
public void testForkHelpQuiesce() { |
221 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
222 |
|
|
public void realCompute() { |
223 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
224 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
225 |
jsr166 |
1.7 |
f.helpQuiesce(); |
226 |
jsr166 |
1.18 |
assertEquals(21, f.result); |
227 |
|
|
assertTrue(f.isDone()); |
228 |
|
|
assertEquals(0, getQueuedTaskCount()); |
229 |
jsr166 |
1.7 |
}}; |
230 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
231 |
dl |
1.1 |
} |
232 |
|
|
|
233 |
|
|
|
234 |
jsr166 |
1.2 |
/** |
235 |
dl |
1.1 |
* invoke task throws exception when task completes abnormally |
236 |
|
|
*/ |
237 |
|
|
public void testAbnormalInvoke() { |
238 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
239 |
|
|
public void realCompute() { |
240 |
|
|
FailingFibAction f = new FailingFibAction(8); |
241 |
jsr166 |
1.7 |
try { |
242 |
|
|
f.invoke(); |
243 |
|
|
shouldThrow(); |
244 |
jsr166 |
1.18 |
} catch (FJException success) {} |
245 |
jsr166 |
1.7 |
}}; |
246 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
247 |
dl |
1.1 |
} |
248 |
|
|
|
249 |
jsr166 |
1.2 |
/** |
250 |
jsr166 |
1.4 |
* quietlyInvoke task returns when task completes abnormally |
251 |
dl |
1.1 |
*/ |
252 |
|
|
public void testAbnormalQuietlyInvoke() { |
253 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
254 |
|
|
public void realCompute() { |
255 |
jsr166 |
1.7 |
FailingFibAction f = new FailingFibAction(8); |
256 |
|
|
f.quietlyInvoke(); |
257 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
258 |
jsr166 |
1.7 |
}}; |
259 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
260 |
dl |
1.1 |
} |
261 |
|
|
|
262 |
jsr166 |
1.2 |
/** |
263 |
dl |
1.1 |
* join of a forked task throws exception when task completes abnormally |
264 |
|
|
*/ |
265 |
|
|
public void testAbnormalForkJoin() { |
266 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
267 |
|
|
public void realCompute() { |
268 |
|
|
FailingFibAction f = new FailingFibAction(8); |
269 |
|
|
assertSame(f, f.fork()); |
270 |
jsr166 |
1.7 |
try { |
271 |
|
|
f.join(); |
272 |
|
|
shouldThrow(); |
273 |
jsr166 |
1.18 |
} catch (FJException success) {} |
274 |
jsr166 |
1.7 |
}}; |
275 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
276 |
dl |
1.1 |
} |
277 |
|
|
|
278 |
jsr166 |
1.2 |
/** |
279 |
dl |
1.1 |
* get of a forked task throws exception when task completes abnormally |
280 |
|
|
*/ |
281 |
|
|
public void testAbnormalForkGet() { |
282 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
283 |
|
|
public void realCompute() throws Exception { |
284 |
|
|
FailingFibAction f = new FailingFibAction(8); |
285 |
|
|
assertSame(f, f.fork()); |
286 |
jsr166 |
1.7 |
try { |
287 |
|
|
f.get(); |
288 |
|
|
shouldThrow(); |
289 |
jsr166 |
1.18 |
} catch (ExecutionException success) {} |
290 |
jsr166 |
1.7 |
}}; |
291 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
292 |
dl |
1.1 |
} |
293 |
|
|
|
294 |
jsr166 |
1.2 |
/** |
295 |
dl |
1.1 |
* timed get of a forked task throws exception when task completes abnormally |
296 |
|
|
*/ |
297 |
|
|
public void testAbnormalForkTimedGet() { |
298 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
299 |
|
|
public void realCompute() throws Exception { |
300 |
|
|
FailingFibAction f = new FailingFibAction(8); |
301 |
|
|
assertSame(f, f.fork()); |
302 |
jsr166 |
1.7 |
try { |
303 |
|
|
f.get(5L, TimeUnit.SECONDS); |
304 |
|
|
shouldThrow(); |
305 |
jsr166 |
1.18 |
} catch (ExecutionException success) {} |
306 |
jsr166 |
1.7 |
}}; |
307 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
308 |
dl |
1.1 |
} |
309 |
|
|
|
310 |
jsr166 |
1.2 |
/** |
311 |
dl |
1.1 |
* quietlyJoin of a forked task returns when task completes abnormally |
312 |
|
|
*/ |
313 |
|
|
public void testAbnormalForkQuietlyJoin() { |
314 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
315 |
|
|
public void realCompute() { |
316 |
jsr166 |
1.7 |
FailingFibAction f = new FailingFibAction(8); |
317 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
318 |
jsr166 |
1.7 |
f.quietlyJoin(); |
319 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
320 |
|
|
assertTrue(f.isCompletedAbnormally()); |
321 |
|
|
assertTrue(f.getException() instanceof FJException); |
322 |
jsr166 |
1.7 |
}}; |
323 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
324 |
dl |
1.1 |
} |
325 |
|
|
|
326 |
jsr166 |
1.2 |
/** |
327 |
dl |
1.1 |
* invoke task throws exception when task cancelled |
328 |
|
|
*/ |
329 |
|
|
public void testCancelledInvoke() { |
330 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
331 |
|
|
public void realCompute() { |
332 |
|
|
FibAction f = new FibAction(8); |
333 |
|
|
assertTrue(f.cancel(true)); |
334 |
jsr166 |
1.7 |
try { |
335 |
|
|
f.invoke(); |
336 |
|
|
shouldThrow(); |
337 |
jsr166 |
1.18 |
} catch (CancellationException success) {} |
338 |
jsr166 |
1.7 |
}}; |
339 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
340 |
dl |
1.1 |
} |
341 |
|
|
|
342 |
jsr166 |
1.2 |
/** |
343 |
dl |
1.1 |
* join of a forked task throws exception when task cancelled |
344 |
|
|
*/ |
345 |
|
|
public void testCancelledForkJoin() { |
346 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
347 |
|
|
public void realCompute() { |
348 |
|
|
FibAction f = new FibAction(8); |
349 |
|
|
assertTrue(f.cancel(true)); |
350 |
|
|
assertSame(f, f.fork()); |
351 |
jsr166 |
1.7 |
try { |
352 |
|
|
f.join(); |
353 |
|
|
shouldThrow(); |
354 |
jsr166 |
1.18 |
} catch (CancellationException success) {} |
355 |
jsr166 |
1.7 |
}}; |
356 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
357 |
dl |
1.1 |
} |
358 |
|
|
|
359 |
jsr166 |
1.2 |
/** |
360 |
dl |
1.1 |
* get of a forked task throws exception when task cancelled |
361 |
|
|
*/ |
362 |
|
|
public void testCancelledForkGet() { |
363 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
364 |
|
|
public void realCompute() throws Exception { |
365 |
|
|
FibAction f = new FibAction(8); |
366 |
|
|
assertTrue(f.cancel(true)); |
367 |
|
|
assertSame(f, f.fork()); |
368 |
jsr166 |
1.7 |
try { |
369 |
|
|
f.get(); |
370 |
|
|
shouldThrow(); |
371 |
jsr166 |
1.18 |
} catch (CancellationException success) {} |
372 |
jsr166 |
1.7 |
}}; |
373 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
374 |
dl |
1.1 |
} |
375 |
|
|
|
376 |
jsr166 |
1.2 |
/** |
377 |
dl |
1.1 |
* timed get of a forked task throws exception when task cancelled |
378 |
|
|
*/ |
379 |
|
|
public void testCancelledForkTimedGet() { |
380 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
381 |
|
|
public void realCompute() throws Exception { |
382 |
|
|
FibAction f = new FibAction(8); |
383 |
|
|
assertTrue(f.cancel(true)); |
384 |
|
|
assertSame(f, f.fork()); |
385 |
jsr166 |
1.7 |
try { |
386 |
|
|
f.get(5L, TimeUnit.SECONDS); |
387 |
|
|
shouldThrow(); |
388 |
jsr166 |
1.18 |
} catch (CancellationException success) {} |
389 |
jsr166 |
1.7 |
}}; |
390 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
391 |
dl |
1.1 |
} |
392 |
|
|
|
393 |
jsr166 |
1.2 |
/** |
394 |
dl |
1.1 |
* quietlyJoin of a forked task returns when task cancelled |
395 |
|
|
*/ |
396 |
|
|
public void testCancelledForkQuietlyJoin() { |
397 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
398 |
|
|
public void realCompute() { |
399 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
400 |
jsr166 |
1.18 |
assertTrue(f.cancel(true)); |
401 |
|
|
assertSame(f, f.fork()); |
402 |
jsr166 |
1.7 |
f.quietlyJoin(); |
403 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
404 |
|
|
assertTrue(f.isCompletedAbnormally()); |
405 |
|
|
assertTrue(f.isCancelled()); |
406 |
|
|
assertTrue(f.getException() instanceof CancellationException); |
407 |
jsr166 |
1.7 |
}}; |
408 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
409 |
dl |
1.1 |
} |
410 |
|
|
|
411 |
|
|
/** |
412 |
|
|
* getPool of executing task returns its pool |
413 |
|
|
*/ |
414 |
|
|
public void testGetPool() { |
415 |
jsr166 |
1.14 |
final ForkJoinPool mainPool = mainPool(); |
416 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
417 |
|
|
public void realCompute() { |
418 |
|
|
assertSame(mainPool, getPool()); |
419 |
jsr166 |
1.7 |
}}; |
420 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool, a); |
421 |
dl |
1.1 |
} |
422 |
|
|
|
423 |
|
|
/** |
424 |
|
|
* getPool of non-FJ task returns null |
425 |
|
|
*/ |
426 |
|
|
public void testGetPool2() { |
427 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
428 |
|
|
public void realCompute() { |
429 |
|
|
assertNull(getPool()); |
430 |
jsr166 |
1.7 |
}}; |
431 |
jsr166 |
1.16 |
assertNull(a.invoke()); |
432 |
dl |
1.1 |
} |
433 |
|
|
|
434 |
|
|
/** |
435 |
|
|
* inForkJoinPool of executing task returns true |
436 |
|
|
*/ |
437 |
|
|
public void testInForkJoinPool() { |
438 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
439 |
|
|
public void realCompute() { |
440 |
|
|
assertTrue(inForkJoinPool()); |
441 |
jsr166 |
1.7 |
}}; |
442 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
443 |
dl |
1.1 |
} |
444 |
|
|
|
445 |
|
|
/** |
446 |
|
|
* inForkJoinPool of non-FJ task returns false |
447 |
|
|
*/ |
448 |
|
|
public void testInForkJoinPool2() { |
449 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
450 |
|
|
public void realCompute() { |
451 |
|
|
assertFalse(inForkJoinPool()); |
452 |
jsr166 |
1.7 |
}}; |
453 |
jsr166 |
1.16 |
assertNull(a.invoke()); |
454 |
dl |
1.1 |
} |
455 |
|
|
|
456 |
|
|
/** |
457 |
|
|
* getPool of current thread in pool returns its pool |
458 |
|
|
*/ |
459 |
|
|
public void testWorkerGetPool() { |
460 |
jsr166 |
1.14 |
final ForkJoinPool mainPool = mainPool(); |
461 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
462 |
|
|
public void realCompute() { |
463 |
jsr166 |
1.7 |
ForkJoinWorkerThread w = |
464 |
jsr166 |
1.14 |
(ForkJoinWorkerThread) Thread.currentThread(); |
465 |
jsr166 |
1.18 |
assertSame(mainPool, w.getPool()); |
466 |
jsr166 |
1.7 |
}}; |
467 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool, a); |
468 |
dl |
1.1 |
} |
469 |
|
|
|
470 |
|
|
/** |
471 |
|
|
* getPoolIndex of current thread in pool returns 0 <= value < poolSize |
472 |
|
|
*/ |
473 |
|
|
public void testWorkerGetPoolIndex() { |
474 |
jsr166 |
1.14 |
final ForkJoinPool mainPool = mainPool(); |
475 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
476 |
|
|
public void realCompute() { |
477 |
jsr166 |
1.7 |
ForkJoinWorkerThread w = |
478 |
|
|
(ForkJoinWorkerThread)(Thread.currentThread()); |
479 |
|
|
int idx = w.getPoolIndex(); |
480 |
jsr166 |
1.18 |
assertTrue(idx >= 0); |
481 |
|
|
assertTrue(idx < mainPool.getPoolSize()); |
482 |
jsr166 |
1.7 |
}}; |
483 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool, a); |
484 |
dl |
1.1 |
} |
485 |
|
|
|
486 |
|
|
|
487 |
|
|
/** |
488 |
|
|
* setRawResult(null) succeeds |
489 |
|
|
*/ |
490 |
|
|
public void testSetRawResult() { |
491 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
492 |
|
|
public void realCompute() { |
493 |
jsr166 |
1.7 |
setRawResult(null); |
494 |
|
|
}}; |
495 |
jsr166 |
1.16 |
assertNull(a.invoke()); |
496 |
dl |
1.1 |
} |
497 |
|
|
|
498 |
jsr166 |
1.2 |
/** |
499 |
dl |
1.1 |
* A reinitialized task may be re-invoked |
500 |
|
|
*/ |
501 |
|
|
public void testReinitialize() { |
502 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
503 |
|
|
public void realCompute() { |
504 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
505 |
jsr166 |
1.18 |
assertNull(f.invoke()); |
506 |
|
|
assertEquals(21, f.result); |
507 |
|
|
assertTrue(f.isDone()); |
508 |
|
|
assertFalse(f.isCancelled()); |
509 |
|
|
assertFalse(f.isCompletedAbnormally()); |
510 |
jsr166 |
1.7 |
f.reinitialize(); |
511 |
jsr166 |
1.18 |
assertNull(f.invoke()); |
512 |
|
|
assertEquals(21, f.result); |
513 |
jsr166 |
1.7 |
}}; |
514 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
515 |
dl |
1.1 |
} |
516 |
|
|
|
517 |
jsr166 |
1.2 |
/** |
518 |
dl |
1.1 |
* invoke task throws exception after invoking completeExceptionally |
519 |
|
|
*/ |
520 |
|
|
public void testCompleteExceptionally() { |
521 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
522 |
|
|
public void realCompute() { |
523 |
|
|
FibAction f = new FibAction(8); |
524 |
|
|
f.completeExceptionally(new FJException()); |
525 |
jsr166 |
1.7 |
try { |
526 |
|
|
f.invoke(); |
527 |
|
|
shouldThrow(); |
528 |
jsr166 |
1.18 |
} catch (FJException success) {} |
529 |
jsr166 |
1.7 |
}}; |
530 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
531 |
dl |
1.1 |
} |
532 |
|
|
|
533 |
jsr166 |
1.2 |
/** |
534 |
dl |
1.1 |
* invoke task suppresses execution invoking complete |
535 |
|
|
*/ |
536 |
|
|
public void testComplete() { |
537 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
538 |
|
|
public void realCompute() { |
539 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
540 |
|
|
f.complete(null); |
541 |
jsr166 |
1.18 |
assertNull(f.invoke()); |
542 |
|
|
assertTrue(f.isDone()); |
543 |
|
|
assertEquals(0, f.result); |
544 |
jsr166 |
1.7 |
}}; |
545 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
546 |
dl |
1.1 |
} |
547 |
|
|
|
548 |
jsr166 |
1.2 |
/** |
549 |
dl |
1.1 |
* invokeAll(t1, t2) invokes all task arguments |
550 |
|
|
*/ |
551 |
|
|
public void testInvokeAll2() { |
552 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
553 |
|
|
public void realCompute() { |
554 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
555 |
|
|
FibAction g = new FibAction(9); |
556 |
|
|
invokeAll(f, g); |
557 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
558 |
|
|
assertEquals(21, f.result); |
559 |
|
|
assertTrue(g.isDone()); |
560 |
|
|
assertEquals(34, g.result); |
561 |
jsr166 |
1.7 |
}}; |
562 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
563 |
dl |
1.1 |
} |
564 |
|
|
|
565 |
jsr166 |
1.2 |
/** |
566 |
dl |
1.1 |
* invokeAll(tasks) with 1 argument invokes task |
567 |
|
|
*/ |
568 |
|
|
public void testInvokeAll1() { |
569 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
570 |
|
|
public void realCompute() { |
571 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
572 |
|
|
invokeAll(f); |
573 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
574 |
|
|
assertEquals(21, f.result); |
575 |
jsr166 |
1.7 |
}}; |
576 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
577 |
dl |
1.1 |
} |
578 |
|
|
|
579 |
jsr166 |
1.2 |
/** |
580 |
dl |
1.1 |
* invokeAll(tasks) with > 2 argument invokes tasks |
581 |
|
|
*/ |
582 |
|
|
public void testInvokeAll3() { |
583 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
584 |
|
|
public void realCompute() { |
585 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
586 |
|
|
FibAction g = new FibAction(9); |
587 |
|
|
FibAction h = new FibAction(7); |
588 |
|
|
invokeAll(f, g, h); |
589 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
590 |
|
|
assertEquals(21, f.result); |
591 |
|
|
assertTrue(g.isDone()); |
592 |
|
|
assertEquals(34, g.result); |
593 |
|
|
assertTrue(h.isDone()); |
594 |
|
|
assertEquals(13, h.result); |
595 |
jsr166 |
1.7 |
}}; |
596 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
597 |
dl |
1.1 |
} |
598 |
|
|
|
599 |
jsr166 |
1.2 |
/** |
600 |
dl |
1.1 |
* invokeAll(collection) invokes all tasks in the collection |
601 |
|
|
*/ |
602 |
|
|
public void testInvokeAllCollection() { |
603 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
604 |
|
|
public void realCompute() { |
605 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
606 |
|
|
FibAction g = new FibAction(9); |
607 |
|
|
FibAction h = new FibAction(7); |
608 |
|
|
HashSet set = new HashSet(); |
609 |
|
|
set.add(f); |
610 |
|
|
set.add(g); |
611 |
|
|
set.add(h); |
612 |
|
|
invokeAll(set); |
613 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
614 |
|
|
assertEquals(21, f.result); |
615 |
|
|
assertTrue(g.isDone()); |
616 |
|
|
assertEquals(34, g.result); |
617 |
|
|
assertTrue(h.isDone()); |
618 |
|
|
assertEquals(13, h.result); |
619 |
jsr166 |
1.7 |
}}; |
620 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
621 |
dl |
1.1 |
} |
622 |
|
|
|
623 |
|
|
|
624 |
jsr166 |
1.2 |
/** |
625 |
dl |
1.1 |
* invokeAll(tasks) with any null task throws NPE |
626 |
|
|
*/ |
627 |
|
|
public void testInvokeAllNPE() { |
628 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
629 |
|
|
public void realCompute() { |
630 |
|
|
FibAction f = new FibAction(8); |
631 |
|
|
FibAction g = new FibAction(9); |
632 |
|
|
FibAction h = null; |
633 |
jsr166 |
1.7 |
try { |
634 |
|
|
invokeAll(f, g, h); |
635 |
|
|
shouldThrow(); |
636 |
jsr166 |
1.18 |
} catch (NullPointerException success) {} |
637 |
jsr166 |
1.7 |
}}; |
638 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
639 |
dl |
1.1 |
} |
640 |
|
|
|
641 |
jsr166 |
1.2 |
/** |
642 |
dl |
1.1 |
* invokeAll(t1, t2) throw exception if any task does |
643 |
|
|
*/ |
644 |
|
|
public void testAbnormalInvokeAll2() { |
645 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
646 |
|
|
public void realCompute() { |
647 |
|
|
FibAction f = new FibAction(8); |
648 |
|
|
FailingFibAction g = new FailingFibAction(9); |
649 |
jsr166 |
1.7 |
try { |
650 |
|
|
invokeAll(f, g); |
651 |
|
|
shouldThrow(); |
652 |
jsr166 |
1.18 |
} catch (FJException success) {} |
653 |
jsr166 |
1.7 |
}}; |
654 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
655 |
dl |
1.1 |
} |
656 |
|
|
|
657 |
jsr166 |
1.2 |
/** |
658 |
dl |
1.1 |
* invokeAll(tasks) with 1 argument throws exception if task does |
659 |
|
|
*/ |
660 |
|
|
public void testAbnormalInvokeAll1() { |
661 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
662 |
|
|
public void realCompute() { |
663 |
|
|
FailingFibAction g = new FailingFibAction(9); |
664 |
jsr166 |
1.7 |
try { |
665 |
|
|
invokeAll(g); |
666 |
|
|
shouldThrow(); |
667 |
jsr166 |
1.18 |
} catch (FJException success) {} |
668 |
jsr166 |
1.7 |
}}; |
669 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
670 |
dl |
1.1 |
} |
671 |
|
|
|
672 |
jsr166 |
1.2 |
/** |
673 |
dl |
1.1 |
* invokeAll(tasks) with > 2 argument throws exception if any task does |
674 |
|
|
*/ |
675 |
|
|
public void testAbnormalInvokeAll3() { |
676 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
677 |
|
|
public void realCompute() { |
678 |
|
|
FibAction f = new FibAction(8); |
679 |
|
|
FailingFibAction g = new FailingFibAction(9); |
680 |
|
|
FibAction h = new FibAction(7); |
681 |
jsr166 |
1.7 |
try { |
682 |
|
|
invokeAll(f, g, h); |
683 |
|
|
shouldThrow(); |
684 |
jsr166 |
1.18 |
} catch (FJException success) {} |
685 |
jsr166 |
1.7 |
}}; |
686 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
687 |
dl |
1.1 |
} |
688 |
|
|
|
689 |
jsr166 |
1.2 |
/** |
690 |
jsr166 |
1.3 |
* invokeAll(collection) throws exception if any task does |
691 |
dl |
1.1 |
*/ |
692 |
|
|
public void testAbnormalInvokeAllCollection() { |
693 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
694 |
|
|
public void realCompute() { |
695 |
|
|
FailingFibAction f = new FailingFibAction(8); |
696 |
|
|
FibAction g = new FibAction(9); |
697 |
|
|
FibAction h = new FibAction(7); |
698 |
|
|
HashSet set = new HashSet(); |
699 |
|
|
set.add(f); |
700 |
|
|
set.add(g); |
701 |
|
|
set.add(h); |
702 |
jsr166 |
1.7 |
try { |
703 |
|
|
invokeAll(set); |
704 |
|
|
shouldThrow(); |
705 |
jsr166 |
1.18 |
} catch (FJException success) {} |
706 |
jsr166 |
1.7 |
}}; |
707 |
jsr166 |
1.14 |
testInvokeOnPool(mainPool(), a); |
708 |
dl |
1.1 |
} |
709 |
|
|
|
710 |
jsr166 |
1.2 |
/** |
711 |
dl |
1.1 |
* tryUnfork returns true for most recent unexecuted task, |
712 |
|
|
* and suppresses execution |
713 |
|
|
*/ |
714 |
|
|
public void testTryUnfork() { |
715 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
716 |
|
|
public void realCompute() { |
717 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
718 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
719 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
720 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
721 |
|
|
assertTrue(f.tryUnfork()); |
722 |
jsr166 |
1.7 |
helpQuiesce(); |
723 |
jsr166 |
1.18 |
assertFalse(f.isDone()); |
724 |
|
|
assertTrue(g.isDone()); |
725 |
jsr166 |
1.7 |
}}; |
726 |
jsr166 |
1.14 |
testInvokeOnPool(singletonPool(), a); |
727 |
dl |
1.1 |
} |
728 |
|
|
|
729 |
jsr166 |
1.2 |
/** |
730 |
dl |
1.1 |
* getSurplusQueuedTaskCount returns > 0 when |
731 |
|
|
* there are more tasks than threads |
732 |
|
|
*/ |
733 |
|
|
public void testGetSurplusQueuedTaskCount() { |
734 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
735 |
|
|
public void realCompute() { |
736 |
jsr166 |
1.7 |
FibAction h = new FibAction(7); |
737 |
jsr166 |
1.18 |
assertSame(h, h.fork()); |
738 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
739 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
740 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
741 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
742 |
|
|
assertTrue(getSurplusQueuedTaskCount() > 0); |
743 |
jsr166 |
1.7 |
helpQuiesce(); |
744 |
|
|
}}; |
745 |
jsr166 |
1.14 |
testInvokeOnPool(singletonPool(), a); |
746 |
dl |
1.1 |
} |
747 |
|
|
|
748 |
jsr166 |
1.2 |
/** |
749 |
dl |
1.1 |
* peekNextLocalTask returns most recent unexecuted task. |
750 |
|
|
*/ |
751 |
|
|
public void testPeekNextLocalTask() { |
752 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
753 |
|
|
public void realCompute() { |
754 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
755 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
756 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
757 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
758 |
|
|
assertSame(f, peekNextLocalTask()); |
759 |
|
|
assertNull(f.join()); |
760 |
|
|
assertTrue(f.isDone()); |
761 |
jsr166 |
1.7 |
helpQuiesce(); |
762 |
|
|
}}; |
763 |
jsr166 |
1.14 |
testInvokeOnPool(singletonPool(), a); |
764 |
dl |
1.1 |
} |
765 |
|
|
|
766 |
jsr166 |
1.2 |
/** |
767 |
dl |
1.1 |
* pollNextLocalTask returns most recent unexecuted task |
768 |
|
|
* without executing it |
769 |
|
|
*/ |
770 |
|
|
public void testPollNextLocalTask() { |
771 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
772 |
|
|
public void realCompute() { |
773 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
774 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
775 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
776 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
777 |
|
|
assertSame(f, pollNextLocalTask()); |
778 |
jsr166 |
1.7 |
helpQuiesce(); |
779 |
jsr166 |
1.18 |
assertFalse(f.isDone()); |
780 |
jsr166 |
1.7 |
}}; |
781 |
jsr166 |
1.14 |
testInvokeOnPool(singletonPool(), a); |
782 |
dl |
1.1 |
} |
783 |
|
|
|
784 |
jsr166 |
1.2 |
/** |
785 |
dl |
1.1 |
* pollTask returns an unexecuted task |
786 |
|
|
* without executing it |
787 |
|
|
*/ |
788 |
|
|
public void testPollTask() { |
789 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
790 |
|
|
public void realCompute() { |
791 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
792 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
793 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
794 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
795 |
|
|
assertSame(f, pollTask()); |
796 |
jsr166 |
1.7 |
helpQuiesce(); |
797 |
jsr166 |
1.18 |
assertFalse(f.isDone()); |
798 |
|
|
assertTrue(g.isDone()); |
799 |
jsr166 |
1.7 |
}}; |
800 |
jsr166 |
1.14 |
testInvokeOnPool(singletonPool(), a); |
801 |
dl |
1.1 |
} |
802 |
|
|
|
803 |
jsr166 |
1.2 |
/** |
804 |
dl |
1.1 |
* peekNextLocalTask returns least recent unexecuted task in async mode |
805 |
|
|
*/ |
806 |
|
|
public void testPeekNextLocalTaskAsync() { |
807 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
808 |
|
|
public void realCompute() { |
809 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
810 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
811 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
812 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
813 |
|
|
assertSame(g, peekNextLocalTask()); |
814 |
|
|
assertNull(f.join()); |
815 |
jsr166 |
1.7 |
helpQuiesce(); |
816 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
817 |
jsr166 |
1.7 |
}}; |
818 |
jsr166 |
1.14 |
testInvokeOnPool(asyncSingletonPool(), a); |
819 |
dl |
1.1 |
} |
820 |
|
|
|
821 |
jsr166 |
1.2 |
/** |
822 |
dl |
1.1 |
* pollNextLocalTask returns least recent unexecuted task |
823 |
|
|
* without executing it, in async mode |
824 |
|
|
*/ |
825 |
|
|
public void testPollNextLocalTaskAsync() { |
826 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
827 |
|
|
public void realCompute() { |
828 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
829 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
830 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
831 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
832 |
|
|
assertSame(g, pollNextLocalTask()); |
833 |
jsr166 |
1.7 |
helpQuiesce(); |
834 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
835 |
|
|
assertFalse(g.isDone()); |
836 |
jsr166 |
1.7 |
}}; |
837 |
jsr166 |
1.14 |
testInvokeOnPool(asyncSingletonPool(), a); |
838 |
dl |
1.1 |
} |
839 |
|
|
|
840 |
jsr166 |
1.2 |
/** |
841 |
dl |
1.1 |
* pollTask returns an unexecuted task |
842 |
|
|
* without executing it, in async mode |
843 |
|
|
*/ |
844 |
|
|
public void testPollTaskAsync() { |
845 |
jsr166 |
1.18 |
RecursiveAction a = new CheckedRecursiveAction() { |
846 |
|
|
public void realCompute() { |
847 |
jsr166 |
1.7 |
FibAction g = new FibAction(9); |
848 |
jsr166 |
1.18 |
assertSame(g, g.fork()); |
849 |
jsr166 |
1.7 |
FibAction f = new FibAction(8); |
850 |
jsr166 |
1.18 |
assertSame(f, f.fork()); |
851 |
|
|
assertSame(g, pollTask()); |
852 |
jsr166 |
1.7 |
helpQuiesce(); |
853 |
jsr166 |
1.18 |
assertTrue(f.isDone()); |
854 |
|
|
assertFalse(g.isDone()); |
855 |
jsr166 |
1.7 |
}}; |
856 |
jsr166 |
1.14 |
testInvokeOnPool(asyncSingletonPool(), a); |
857 |
dl |
1.1 |
} |
858 |
|
|
|
859 |
|
|
} |