3 |
|
* Expert Group and released to the public domain, as explained at |
4 |
|
* http://creativecommons.org/licenses/publicdomain |
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.ForkJoinWorkerThread; |
12 |
+ |
import java.util.concurrent.RecursiveAction; |
13 |
+ |
import java.util.concurrent.TimeUnit; |
14 |
+ |
import java.util.HashSet; |
15 |
|
|
16 |
|
public class RecursiveActionTest extends JSR166TestCase { |
17 |
|
|
18 |
|
public static void main(String[] args) { |
19 |
|
junit.textui.TestRunner.run(suite()); |
20 |
|
} |
21 |
+ |
|
22 |
|
public static Test suite() { |
23 |
|
return new TestSuite(RecursiveActionTest.class); |
24 |
|
} |
25 |
|
|
26 |
< |
static final ForkJoinPool mainPool = new ForkJoinPool(); |
27 |
< |
static final ForkJoinPool singletonPool = new ForkJoinPool(1); |
28 |
< |
static final ForkJoinPool asyncSingletonPool = |
29 |
< |
new ForkJoinPool(1, ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
30 |
< |
null, true); |
26 |
> |
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 |
> |
assertTrue(pool.invoke(a) == null); |
43 |
> |
} finally { |
44 |
> |
joinPool(pool); |
45 |
> |
} |
46 |
> |
} |
47 |
|
|
48 |
|
static final class FJException extends RuntimeException { |
49 |
|
FJException() { super(); } |
89 |
|
* invoke returns when task completes normally. |
90 |
|
* isCompletedAbnormally and isCancelled return false for normally |
91 |
|
* completed tasks. getRawResult of a RecursiveAction returns null; |
70 |
– |
* |
92 |
|
*/ |
93 |
|
public void testInvoke() { |
94 |
|
RecursiveAction a = new RecursiveAction() { |
95 |
|
public void compute() { |
96 |
|
FibAction f = new FibAction(8); |
97 |
< |
f.invoke(); |
97 |
> |
threadAssertNull(f.invoke()); |
98 |
|
threadAssertTrue(f.result == 21); |
99 |
|
threadAssertTrue(f.isDone()); |
100 |
|
threadAssertFalse(f.isCancelled()); |
101 |
|
threadAssertFalse(f.isCompletedAbnormally()); |
102 |
|
threadAssertTrue(f.getRawResult() == null); |
103 |
|
}}; |
104 |
< |
mainPool.invoke(a); |
104 |
> |
testInvokeOnPool(mainPool(), a); |
105 |
|
} |
106 |
|
|
107 |
|
/** |
120 |
|
threadAssertFalse(f.isCompletedAbnormally()); |
121 |
|
threadAssertTrue(f.getRawResult() == null); |
122 |
|
}}; |
123 |
< |
mainPool.invoke(a); |
123 |
> |
testInvokeOnPool(mainPool(), a); |
124 |
|
} |
125 |
|
|
126 |
|
/** |
130 |
|
RecursiveAction a = new RecursiveAction() { |
131 |
|
public void compute() { |
132 |
|
FibAction f = new FibAction(8); |
133 |
< |
f.fork(); |
134 |
< |
f.join(); |
133 |
> |
threadAssertSame(f, f.fork()); |
134 |
> |
threadAssertNull(f.join()); |
135 |
|
threadAssertTrue(f.result == 21); |
136 |
|
threadAssertTrue(f.isDone()); |
137 |
|
threadAssertTrue(f.getRawResult() == null); |
138 |
|
}}; |
139 |
< |
mainPool.invoke(a); |
139 |
> |
testInvokeOnPool(mainPool(), a); |
140 |
|
} |
141 |
|
|
142 |
|
/** |
147 |
|
public void compute() { |
148 |
|
try { |
149 |
|
FibAction f = new FibAction(8); |
150 |
< |
f.fork(); |
151 |
< |
f.get(); |
150 |
> |
threadAssertSame(f, f.fork()); |
151 |
> |
threadAssertNull(f.get()); |
152 |
|
threadAssertTrue(f.result == 21); |
153 |
|
threadAssertTrue(f.isDone()); |
154 |
|
} catch (Exception ex) { |
155 |
|
unexpectedException(ex); |
156 |
|
} |
157 |
|
}}; |
158 |
< |
mainPool.invoke(a); |
158 |
> |
testInvokeOnPool(mainPool(), a); |
159 |
|
} |
160 |
|
|
161 |
|
/** |
166 |
|
public void compute() { |
167 |
|
try { |
168 |
|
FibAction f = new FibAction(8); |
169 |
< |
f.fork(); |
170 |
< |
f.get(5L, TimeUnit.SECONDS); |
169 |
> |
threadAssertSame(f, f.fork()); |
170 |
> |
threadAssertNull(f.get(5L, TimeUnit.SECONDS)); |
171 |
|
threadAssertTrue(f.result == 21); |
172 |
|
threadAssertTrue(f.isDone()); |
173 |
|
} catch (Exception ex) { |
174 |
|
unexpectedException(ex); |
175 |
|
} |
176 |
|
}}; |
177 |
< |
mainPool.invoke(a); |
177 |
> |
testInvokeOnPool(mainPool(), a); |
178 |
|
} |
179 |
|
|
180 |
|
/** |
185 |
|
public void compute() { |
186 |
|
try { |
187 |
|
FibAction f = new FibAction(8); |
188 |
< |
f.fork(); |
188 |
> |
threadAssertSame(f, f.fork()); |
189 |
|
f.get(5L, null); |
190 |
|
shouldThrow(); |
191 |
|
} catch (NullPointerException success) { |
193 |
|
unexpectedException(ex); |
194 |
|
} |
195 |
|
}}; |
196 |
< |
mainPool.invoke(a); |
196 |
> |
testInvokeOnPool(mainPool(), a); |
197 |
|
} |
198 |
|
|
199 |
|
/** |
203 |
|
RecursiveAction a = new RecursiveAction() { |
204 |
|
public void compute() { |
205 |
|
FibAction f = new FibAction(8); |
206 |
< |
f.fork(); |
206 |
> |
threadAssertSame(f, f.fork()); |
207 |
|
f.quietlyJoin(); |
208 |
|
threadAssertTrue(f.result == 21); |
209 |
|
threadAssertTrue(f.isDone()); |
210 |
|
}}; |
211 |
< |
mainPool.invoke(a); |
211 |
> |
testInvokeOnPool(mainPool(), a); |
212 |
|
} |
213 |
|
|
214 |
|
|
220 |
|
RecursiveAction a = new RecursiveAction() { |
221 |
|
public void compute() { |
222 |
|
FibAction f = new FibAction(8); |
223 |
< |
f.fork(); |
223 |
> |
threadAssertSame(f, f.fork()); |
224 |
|
f.helpQuiesce(); |
225 |
|
threadAssertTrue(f.result == 21); |
226 |
|
threadAssertTrue(f.isDone()); |
227 |
|
threadAssertTrue(getQueuedTaskCount() == 0); |
228 |
|
}}; |
229 |
< |
mainPool.invoke(a); |
229 |
> |
testInvokeOnPool(mainPool(), a); |
230 |
|
} |
231 |
|
|
232 |
|
|
243 |
|
} catch (FJException success) { |
244 |
|
} |
245 |
|
}}; |
246 |
< |
mainPool.invoke(a); |
246 |
> |
testInvokeOnPool(mainPool(), a); |
247 |
|
} |
248 |
|
|
249 |
|
/** |
256 |
|
f.quietlyInvoke(); |
257 |
|
threadAssertTrue(f.isDone()); |
258 |
|
}}; |
259 |
< |
mainPool.invoke(a); |
259 |
> |
testInvokeOnPool(mainPool(), a); |
260 |
|
} |
261 |
|
|
262 |
|
/** |
267 |
|
public void compute() { |
268 |
|
try { |
269 |
|
FailingFibAction f = new FailingFibAction(8); |
270 |
< |
f.fork(); |
270 |
> |
threadAssertSame(f, f.fork()); |
271 |
|
f.join(); |
272 |
|
shouldThrow(); |
273 |
|
} catch (FJException success) { |
274 |
|
} |
275 |
|
}}; |
276 |
< |
mainPool.invoke(a); |
276 |
> |
testInvokeOnPool(mainPool(), a); |
277 |
|
} |
278 |
|
|
279 |
|
/** |
284 |
|
public void compute() { |
285 |
|
try { |
286 |
|
FailingFibAction f = new FailingFibAction(8); |
287 |
< |
f.fork(); |
287 |
> |
threadAssertSame(f, f.fork()); |
288 |
|
f.get(); |
289 |
|
shouldThrow(); |
290 |
|
} catch (ExecutionException success) { |
292 |
|
unexpectedException(ex); |
293 |
|
} |
294 |
|
}}; |
295 |
< |
mainPool.invoke(a); |
295 |
> |
testInvokeOnPool(mainPool(), a); |
296 |
|
} |
297 |
|
|
298 |
|
/** |
303 |
|
public void compute() { |
304 |
|
try { |
305 |
|
FailingFibAction f = new FailingFibAction(8); |
306 |
< |
f.fork(); |
306 |
> |
threadAssertSame(f, f.fork()); |
307 |
|
f.get(5L, TimeUnit.SECONDS); |
308 |
|
shouldThrow(); |
309 |
|
} catch (ExecutionException success) { |
311 |
|
unexpectedException(ex); |
312 |
|
} |
313 |
|
}}; |
314 |
< |
mainPool.invoke(a); |
314 |
> |
testInvokeOnPool(mainPool(), a); |
315 |
|
} |
316 |
|
|
317 |
|
/** |
321 |
|
RecursiveAction a = new RecursiveAction() { |
322 |
|
public void compute() { |
323 |
|
FailingFibAction f = new FailingFibAction(8); |
324 |
< |
f.fork(); |
324 |
> |
threadAssertSame(f, f.fork()); |
325 |
|
f.quietlyJoin(); |
326 |
|
threadAssertTrue(f.isDone()); |
327 |
|
threadAssertTrue(f.isCompletedAbnormally()); |
328 |
|
threadAssertTrue(f.getException() instanceof FJException); |
329 |
|
}}; |
330 |
< |
mainPool.invoke(a); |
330 |
> |
testInvokeOnPool(mainPool(), a); |
331 |
|
} |
332 |
|
|
333 |
|
/** |
338 |
|
public void compute() { |
339 |
|
try { |
340 |
|
FibAction f = new FibAction(8); |
341 |
< |
f.cancel(true); |
341 |
> |
threadAssertTrue(f.cancel(true)); |
342 |
|
f.invoke(); |
343 |
|
shouldThrow(); |
344 |
|
} catch (CancellationException success) { |
345 |
|
} |
346 |
|
}}; |
347 |
< |
mainPool.invoke(a); |
347 |
> |
testInvokeOnPool(mainPool(), a); |
348 |
|
} |
349 |
|
|
350 |
|
/** |
355 |
|
public void compute() { |
356 |
|
try { |
357 |
|
FibAction f = new FibAction(8); |
358 |
< |
f.cancel(true); |
359 |
< |
f.fork(); |
358 |
> |
threadAssertTrue(f.cancel(true)); |
359 |
> |
threadAssertSame(f, f.fork()); |
360 |
|
f.join(); |
361 |
|
shouldThrow(); |
362 |
|
} catch (CancellationException success) { |
363 |
|
} |
364 |
|
}}; |
365 |
< |
mainPool.invoke(a); |
365 |
> |
testInvokeOnPool(mainPool(), a); |
366 |
|
} |
367 |
|
|
368 |
|
/** |
373 |
|
public void compute() { |
374 |
|
try { |
375 |
|
FibAction f = new FibAction(8); |
376 |
< |
f.cancel(true); |
377 |
< |
f.fork(); |
376 |
> |
threadAssertTrue(f.cancel(true)); |
377 |
> |
threadAssertSame(f, f.fork()); |
378 |
|
f.get(); |
379 |
|
shouldThrow(); |
380 |
|
} catch (CancellationException success) { |
382 |
|
unexpectedException(ex); |
383 |
|
} |
384 |
|
}}; |
385 |
< |
mainPool.invoke(a); |
385 |
> |
testInvokeOnPool(mainPool(), a); |
386 |
|
} |
387 |
|
|
388 |
|
/** |
393 |
|
public void compute() { |
394 |
|
try { |
395 |
|
FibAction f = new FibAction(8); |
396 |
< |
f.cancel(true); |
397 |
< |
f.fork(); |
396 |
> |
threadAssertTrue(f.cancel(true)); |
397 |
> |
threadAssertSame(f, f.fork()); |
398 |
|
f.get(5L, TimeUnit.SECONDS); |
399 |
|
shouldThrow(); |
400 |
|
} catch (CancellationException success) { |
402 |
|
unexpectedException(ex); |
403 |
|
} |
404 |
|
}}; |
405 |
< |
mainPool.invoke(a); |
405 |
> |
testInvokeOnPool(mainPool(), a); |
406 |
|
} |
407 |
|
|
408 |
|
/** |
412 |
|
RecursiveAction a = new RecursiveAction() { |
413 |
|
public void compute() { |
414 |
|
FibAction f = new FibAction(8); |
415 |
< |
f.cancel(true); |
416 |
< |
f.fork(); |
415 |
> |
threadAssertTrue(f.cancel(true)); |
416 |
> |
threadAssertSame(f, f.fork()); |
417 |
|
f.quietlyJoin(); |
418 |
|
threadAssertTrue(f.isDone()); |
419 |
|
threadAssertTrue(f.isCompletedAbnormally()); |
420 |
|
threadAssertTrue(f.getException() instanceof CancellationException); |
421 |
|
}}; |
422 |
< |
mainPool.invoke(a); |
422 |
> |
testInvokeOnPool(mainPool(), a); |
423 |
|
} |
424 |
|
|
425 |
|
/** |
426 |
|
* getPool of executing task returns its pool |
427 |
|
*/ |
428 |
|
public void testGetPool() { |
429 |
+ |
final ForkJoinPool mainPool = mainPool(); |
430 |
|
RecursiveAction a = new RecursiveAction() { |
431 |
+ |
final ForkJoinPool p = mainPool; |
432 |
|
public void compute() { |
433 |
< |
threadAssertTrue(getPool() == mainPool); |
433 |
> |
threadAssertTrue(getPool() == p); |
434 |
|
}}; |
435 |
< |
mainPool.invoke(a); |
435 |
> |
testInvokeOnPool(mainPool, a); |
436 |
|
} |
437 |
|
|
438 |
|
/** |
443 |
|
public void compute() { |
444 |
|
threadAssertTrue(getPool() == null); |
445 |
|
}}; |
446 |
< |
a.invoke(); |
446 |
> |
assertNull(a.invoke()); |
447 |
|
} |
448 |
|
|
449 |
|
/** |
454 |
|
public void compute() { |
455 |
|
threadAssertTrue(inForkJoinPool()); |
456 |
|
}}; |
457 |
< |
mainPool.invoke(a); |
457 |
> |
testInvokeOnPool(mainPool(), a); |
458 |
|
} |
459 |
|
|
460 |
|
/** |
465 |
|
public void compute() { |
466 |
|
threadAssertTrue(!inForkJoinPool()); |
467 |
|
}}; |
468 |
< |
a.invoke(); |
468 |
> |
assertNull(a.invoke()); |
469 |
|
} |
470 |
|
|
471 |
|
/** |
472 |
|
* getPool of current thread in pool returns its pool |
473 |
|
*/ |
474 |
|
public void testWorkerGetPool() { |
475 |
+ |
final ForkJoinPool mainPool = mainPool(); |
476 |
|
RecursiveAction a = new RecursiveAction() { |
477 |
|
public void compute() { |
478 |
|
ForkJoinWorkerThread w = |
479 |
< |
(ForkJoinWorkerThread)(Thread.currentThread()); |
479 |
> |
(ForkJoinWorkerThread) Thread.currentThread(); |
480 |
|
threadAssertTrue(w.getPool() == mainPool); |
481 |
|
}}; |
482 |
< |
mainPool.invoke(a); |
482 |
> |
testInvokeOnPool(mainPool, a); |
483 |
|
} |
484 |
|
|
485 |
|
/** |
486 |
|
* getPoolIndex of current thread in pool returns 0 <= value < poolSize |
463 |
– |
* |
487 |
|
*/ |
488 |
|
public void testWorkerGetPoolIndex() { |
489 |
+ |
final ForkJoinPool mainPool = mainPool(); |
490 |
|
RecursiveAction a = new RecursiveAction() { |
491 |
|
public void compute() { |
492 |
|
ForkJoinWorkerThread w = |
495 |
|
threadAssertTrue(idx >= 0); |
496 |
|
threadAssertTrue(idx < mainPool.getPoolSize()); |
497 |
|
}}; |
498 |
< |
mainPool.invoke(a); |
498 |
> |
testInvokeOnPool(mainPool, a); |
499 |
|
} |
500 |
|
|
501 |
|
|
507 |
|
public void compute() { |
508 |
|
setRawResult(null); |
509 |
|
}}; |
510 |
< |
a.invoke(); |
510 |
> |
assertNull(a.invoke()); |
511 |
|
} |
512 |
|
|
513 |
|
/** |
517 |
|
RecursiveAction a = new RecursiveAction() { |
518 |
|
public void compute() { |
519 |
|
FibAction f = new FibAction(8); |
520 |
< |
f.invoke(); |
520 |
> |
threadAssertNull(f.invoke()); |
521 |
|
threadAssertTrue(f.result == 21); |
522 |
|
threadAssertTrue(f.isDone()); |
523 |
|
threadAssertFalse(f.isCancelled()); |
524 |
|
threadAssertFalse(f.isCompletedAbnormally()); |
525 |
|
f.reinitialize(); |
526 |
< |
f.invoke(); |
526 |
> |
threadAssertNull(f.invoke()); |
527 |
|
threadAssertTrue(f.result == 21); |
528 |
|
}}; |
529 |
< |
mainPool.invoke(a); |
529 |
> |
testInvokeOnPool(mainPool(), a); |
530 |
|
} |
531 |
|
|
532 |
|
/** |
543 |
|
} catch (FJException success) { |
544 |
|
} |
545 |
|
}}; |
546 |
< |
mainPool.invoke(a); |
546 |
> |
testInvokeOnPool(mainPool(), a); |
547 |
|
} |
548 |
|
|
549 |
|
/** |
554 |
|
public void compute() { |
555 |
|
FibAction f = new FibAction(8); |
556 |
|
f.complete(null); |
557 |
< |
f.invoke(); |
557 |
> |
threadAssertNull(f.invoke()); |
558 |
|
threadAssertTrue(f.isDone()); |
559 |
|
threadAssertTrue(f.result == 0); |
560 |
|
}}; |
561 |
< |
mainPool.invoke(a); |
561 |
> |
testInvokeOnPool(mainPool(), a); |
562 |
|
} |
563 |
|
|
564 |
|
/** |
575 |
|
threadAssertTrue(g.isDone()); |
576 |
|
threadAssertTrue(g.result == 34); |
577 |
|
}}; |
578 |
< |
mainPool.invoke(a); |
578 |
> |
testInvokeOnPool(mainPool(), a); |
579 |
|
} |
580 |
|
|
581 |
|
/** |
589 |
|
threadAssertTrue(f.isDone()); |
590 |
|
threadAssertTrue(f.result == 21); |
591 |
|
}}; |
592 |
< |
mainPool.invoke(a); |
592 |
> |
testInvokeOnPool(mainPool(), a); |
593 |
|
} |
594 |
|
|
595 |
|
/** |
609 |
|
threadAssertTrue(h.isDone()); |
610 |
|
threadAssertTrue(h.result == 13); |
611 |
|
}}; |
612 |
< |
mainPool.invoke(a); |
612 |
> |
testInvokeOnPool(mainPool(), a); |
613 |
|
} |
614 |
|
|
615 |
|
/** |
633 |
|
threadAssertTrue(h.isDone()); |
634 |
|
threadAssertTrue(h.result == 13); |
635 |
|
}}; |
636 |
< |
mainPool.invoke(a); |
636 |
> |
testInvokeOnPool(mainPool(), a); |
637 |
|
} |
638 |
|
|
639 |
|
|
652 |
|
} catch (NullPointerException success) { |
653 |
|
} |
654 |
|
}}; |
655 |
< |
mainPool.invoke(a); |
655 |
> |
testInvokeOnPool(mainPool(), a); |
656 |
|
} |
657 |
|
|
658 |
|
/** |
669 |
|
} catch (FJException success) { |
670 |
|
} |
671 |
|
}}; |
672 |
< |
mainPool.invoke(a); |
672 |
> |
testInvokeOnPool(mainPool(), a); |
673 |
|
} |
674 |
|
|
675 |
|
/** |
685 |
|
} catch (FJException success) { |
686 |
|
} |
687 |
|
}}; |
688 |
< |
mainPool.invoke(a); |
688 |
> |
testInvokeOnPool(mainPool(), a); |
689 |
|
} |
690 |
|
|
691 |
|
/** |
703 |
|
} catch (FJException success) { |
704 |
|
} |
705 |
|
}}; |
706 |
< |
mainPool.invoke(a); |
706 |
> |
testInvokeOnPool(mainPool(), a); |
707 |
|
} |
708 |
|
|
709 |
|
/** |
725 |
|
} catch (FJException success) { |
726 |
|
} |
727 |
|
}}; |
728 |
< |
mainPool.invoke(a); |
728 |
> |
testInvokeOnPool(mainPool(), a); |
729 |
|
} |
730 |
|
|
731 |
|
/** |
736 |
|
RecursiveAction a = new RecursiveAction() { |
737 |
|
public void compute() { |
738 |
|
FibAction g = new FibAction(9); |
739 |
< |
g.fork(); |
739 |
> |
threadAssertSame(g, g.fork()); |
740 |
|
FibAction f = new FibAction(8); |
741 |
< |
f.fork(); |
741 |
> |
threadAssertSame(f, f.fork()); |
742 |
|
threadAssertTrue(f.tryUnfork()); |
743 |
|
helpQuiesce(); |
744 |
|
threadAssertFalse(f.isDone()); |
745 |
|
threadAssertTrue(g.isDone()); |
746 |
|
}}; |
747 |
< |
singletonPool.invoke(a); |
747 |
> |
testInvokeOnPool(singletonPool(), a); |
748 |
|
} |
749 |
|
|
750 |
|
/** |
755 |
|
RecursiveAction a = new RecursiveAction() { |
756 |
|
public void compute() { |
757 |
|
FibAction h = new FibAction(7); |
758 |
< |
h.fork(); |
758 |
> |
threadAssertSame(h, h.fork()); |
759 |
|
FibAction g = new FibAction(9); |
760 |
< |
g.fork(); |
760 |
> |
threadAssertSame(g, g.fork()); |
761 |
|
FibAction f = new FibAction(8); |
762 |
< |
f.fork(); |
762 |
> |
threadAssertSame(f, f.fork()); |
763 |
|
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
764 |
|
helpQuiesce(); |
765 |
|
}}; |
766 |
< |
singletonPool.invoke(a); |
766 |
> |
testInvokeOnPool(singletonPool(), a); |
767 |
|
} |
768 |
|
|
769 |
|
/** |
773 |
|
RecursiveAction a = new RecursiveAction() { |
774 |
|
public void compute() { |
775 |
|
FibAction g = new FibAction(9); |
776 |
< |
g.fork(); |
776 |
> |
threadAssertSame(g, g.fork()); |
777 |
|
FibAction f = new FibAction(8); |
778 |
< |
f.fork(); |
778 |
> |
threadAssertSame(f, f.fork()); |
779 |
|
threadAssertTrue(peekNextLocalTask() == f); |
780 |
< |
f.join(); |
780 |
> |
threadAssertNull(f.join()); |
781 |
|
threadAssertTrue(f.isDone()); |
782 |
|
helpQuiesce(); |
783 |
|
}}; |
784 |
< |
singletonPool.invoke(a); |
784 |
> |
testInvokeOnPool(singletonPool(), a); |
785 |
|
} |
786 |
|
|
787 |
|
/** |
792 |
|
RecursiveAction a = new RecursiveAction() { |
793 |
|
public void compute() { |
794 |
|
FibAction g = new FibAction(9); |
795 |
< |
g.fork(); |
795 |
> |
threadAssertSame(g, g.fork()); |
796 |
|
FibAction f = new FibAction(8); |
797 |
< |
f.fork(); |
797 |
> |
threadAssertSame(f, f.fork()); |
798 |
|
threadAssertTrue(pollNextLocalTask() == f); |
799 |
|
helpQuiesce(); |
800 |
|
threadAssertFalse(f.isDone()); |
801 |
|
}}; |
802 |
< |
singletonPool.invoke(a); |
802 |
> |
testInvokeOnPool(singletonPool(), a); |
803 |
|
} |
804 |
|
|
805 |
|
/** |
810 |
|
RecursiveAction a = new RecursiveAction() { |
811 |
|
public void compute() { |
812 |
|
FibAction g = new FibAction(9); |
813 |
< |
g.fork(); |
813 |
> |
threadAssertSame(g, g.fork()); |
814 |
|
FibAction f = new FibAction(8); |
815 |
< |
f.fork(); |
815 |
> |
threadAssertSame(f, f.fork()); |
816 |
|
threadAssertTrue(pollTask() == f); |
817 |
|
helpQuiesce(); |
818 |
|
threadAssertFalse(f.isDone()); |
819 |
|
threadAssertTrue(g.isDone()); |
820 |
|
}}; |
821 |
< |
singletonPool.invoke(a); |
821 |
> |
testInvokeOnPool(singletonPool(), a); |
822 |
|
} |
823 |
|
|
824 |
|
/** |
828 |
|
RecursiveAction a = new RecursiveAction() { |
829 |
|
public void compute() { |
830 |
|
FibAction g = new FibAction(9); |
831 |
< |
g.fork(); |
831 |
> |
threadAssertSame(g, g.fork()); |
832 |
|
FibAction f = new FibAction(8); |
833 |
< |
f.fork(); |
833 |
> |
threadAssertSame(f, f.fork()); |
834 |
|
threadAssertTrue(peekNextLocalTask() == g); |
835 |
< |
f.join(); |
835 |
> |
threadAssertNull(f.join()); |
836 |
|
helpQuiesce(); |
837 |
|
threadAssertTrue(f.isDone()); |
838 |
|
}}; |
839 |
< |
asyncSingletonPool.invoke(a); |
839 |
> |
testInvokeOnPool(asyncSingletonPool(), a); |
840 |
|
} |
841 |
|
|
842 |
|
/** |
847 |
|
RecursiveAction a = new RecursiveAction() { |
848 |
|
public void compute() { |
849 |
|
FibAction g = new FibAction(9); |
850 |
< |
g.fork(); |
850 |
> |
threadAssertSame(g, g.fork()); |
851 |
|
FibAction f = new FibAction(8); |
852 |
< |
f.fork(); |
852 |
> |
threadAssertSame(f, f.fork()); |
853 |
|
threadAssertTrue(pollNextLocalTask() == g); |
854 |
|
helpQuiesce(); |
855 |
|
threadAssertTrue(f.isDone()); |
856 |
|
threadAssertFalse(g.isDone()); |
857 |
|
}}; |
858 |
< |
asyncSingletonPool.invoke(a); |
858 |
> |
testInvokeOnPool(asyncSingletonPool(), a); |
859 |
|
} |
860 |
|
|
861 |
|
/** |
866 |
|
RecursiveAction a = new RecursiveAction() { |
867 |
|
public void compute() { |
868 |
|
FibAction g = new FibAction(9); |
869 |
< |
g.fork(); |
869 |
> |
threadAssertSame(g, g.fork()); |
870 |
|
FibAction f = new FibAction(8); |
871 |
< |
f.fork(); |
871 |
> |
threadAssertSame(f, f.fork()); |
872 |
|
threadAssertTrue(pollTask() == g); |
873 |
|
helpQuiesce(); |
874 |
|
threadAssertTrue(f.isDone()); |
875 |
|
threadAssertFalse(g.isDone()); |
876 |
|
}}; |
877 |
< |
asyncSingletonPool.invoke(a); |
877 |
> |
testInvokeOnPool(asyncSingletonPool(), a); |
878 |
|
} |
879 |
|
|
880 |
|
} |