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.RecursiveTask; |
12 |
+ |
import java.util.concurrent.TimeUnit; |
13 |
+ |
import java.util.HashSet; |
14 |
|
|
15 |
|
public class RecursiveTaskTest extends JSR166TestCase { |
16 |
|
|
21 |
|
return new TestSuite(RecursiveTaskTest.class); |
22 |
|
} |
23 |
|
|
24 |
< |
static final ForkJoinPool mainPool = new ForkJoinPool(); |
25 |
< |
static final ForkJoinPool singletonPool = new ForkJoinPool(1); |
26 |
< |
static final ForkJoinPool asyncSingletonPool = |
27 |
< |
new ForkJoinPool(1, ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
28 |
< |
null, true); |
24 |
> |
private static ForkJoinPool mainPool() { |
25 |
> |
return new ForkJoinPool(); |
26 |
> |
} |
27 |
> |
|
28 |
> |
private static ForkJoinPool singletonPool() { |
29 |
> |
return new ForkJoinPool(1); |
30 |
> |
} |
31 |
> |
|
32 |
> |
private static ForkJoinPool asyncSingletonPool() { |
33 |
> |
return new ForkJoinPool(1, |
34 |
> |
ForkJoinPool.defaultForkJoinWorkerThreadFactory, |
35 |
> |
null, true); |
36 |
> |
} |
37 |
> |
|
38 |
> |
private <T> T testInvokeOnPool(ForkJoinPool pool, RecursiveTask<T> a) { |
39 |
> |
try { |
40 |
> |
return pool.invoke(a); |
41 |
> |
} finally { |
42 |
> |
joinPool(pool); |
43 |
> |
} |
44 |
> |
} |
45 |
|
|
46 |
|
static final class FJException extends RuntimeException { |
47 |
|
FJException() { super(); } |
84 |
|
* isCompletedAbnormally and isCancelled return false for normally |
85 |
|
* completed tasks. getRawResult of a completed non-null task |
86 |
|
* returns value; |
67 |
– |
* |
87 |
|
*/ |
88 |
|
public void testInvoke() { |
89 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
98 |
|
return r; |
99 |
|
} |
100 |
|
}; |
101 |
< |
assertTrue(mainPool.invoke(a) == 21); |
101 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
102 |
|
} |
103 |
|
|
104 |
|
/** |
119 |
|
return r; |
120 |
|
} |
121 |
|
}; |
122 |
< |
assertTrue(mainPool.invoke(a) == 21); |
122 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
123 |
|
} |
124 |
|
|
125 |
|
/** |
129 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
130 |
|
public Integer compute() { |
131 |
|
FibTask f = new FibTask(8); |
132 |
< |
f.fork(); |
132 |
> |
threadAssertSame(f, f.fork()); |
133 |
|
Integer r = f.join(); |
134 |
|
threadAssertTrue(r == 21); |
135 |
|
threadAssertTrue(f.isDone()); |
136 |
|
return r; |
137 |
|
} |
138 |
|
}; |
139 |
< |
assertTrue(mainPool.invoke(a) == 21); |
139 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
140 |
|
} |
141 |
|
|
142 |
|
/** |
147 |
|
public Integer compute() { |
148 |
|
try { |
149 |
|
FibTask f = new FibTask(8); |
150 |
< |
f.fork(); |
150 |
> |
threadAssertSame(f, f.fork()); |
151 |
|
Integer r = f.get(); |
152 |
|
threadAssertTrue(r == 21); |
153 |
|
threadAssertTrue(f.isDone()); |
158 |
|
return NoResult; |
159 |
|
} |
160 |
|
}; |
161 |
< |
assertTrue(mainPool.invoke(a) == 21); |
161 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
162 |
|
} |
163 |
|
|
164 |
|
/** |
169 |
|
public Integer compute() { |
170 |
|
try { |
171 |
|
FibTask f = new FibTask(8); |
172 |
< |
f.fork(); |
172 |
> |
threadAssertSame(f, f.fork()); |
173 |
|
Integer r = f.get(5L, TimeUnit.SECONDS); |
174 |
|
threadAssertTrue(r == 21); |
175 |
|
threadAssertTrue(f.isDone()); |
180 |
|
return NoResult; |
181 |
|
} |
182 |
|
}; |
183 |
< |
assertTrue(mainPool.invoke(a) == 21); |
183 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
184 |
|
} |
185 |
|
|
186 |
|
/** |
190 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
191 |
|
public Integer compute() { |
192 |
|
FibTask f = new FibTask(8); |
193 |
< |
f.fork(); |
193 |
> |
threadAssertSame(f, f.fork()); |
194 |
|
f.quietlyJoin(); |
195 |
|
Integer r = f.getRawResult(); |
196 |
|
threadAssertTrue(r == 21); |
198 |
|
return r; |
199 |
|
} |
200 |
|
}; |
201 |
< |
assertTrue(mainPool.invoke(a) == 21); |
201 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
202 |
|
} |
203 |
|
|
204 |
|
|
210 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
211 |
|
public Integer compute() { |
212 |
|
FibTask f = new FibTask(8); |
213 |
< |
f.fork(); |
213 |
> |
threadAssertSame(f, f.fork()); |
214 |
|
f.helpQuiesce(); |
215 |
|
Integer r = f.getRawResult(); |
216 |
|
threadAssertTrue(r == 21); |
219 |
|
return r; |
220 |
|
} |
221 |
|
}; |
222 |
< |
assertTrue(mainPool.invoke(a) == 21); |
222 |
> |
assertEquals(21, (int) testInvokeOnPool(mainPool(), a)); |
223 |
|
} |
224 |
|
|
225 |
|
|
239 |
|
return NoResult; |
240 |
|
} |
241 |
|
}; |
242 |
< |
mainPool.invoke(a); |
242 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
243 |
|
} |
244 |
|
|
245 |
|
/** |
254 |
|
return NoResult; |
255 |
|
} |
256 |
|
}; |
257 |
< |
mainPool.invoke(a); |
257 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
258 |
|
} |
259 |
|
|
260 |
|
/** |
265 |
|
public Integer compute() { |
266 |
|
try { |
267 |
|
FailingFibTask f = new FailingFibTask(8); |
268 |
< |
f.fork(); |
268 |
> |
threadAssertSame(f, f.fork()); |
269 |
|
Integer r = f.join(); |
270 |
|
shouldThrow(); |
271 |
|
return r; |
274 |
|
return NoResult; |
275 |
|
} |
276 |
|
}; |
277 |
< |
mainPool.invoke(a); |
277 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
278 |
|
} |
279 |
|
|
280 |
|
/** |
285 |
|
public Integer compute() { |
286 |
|
try { |
287 |
|
FailingFibTask f = new FailingFibTask(8); |
288 |
< |
f.fork(); |
288 |
> |
threadAssertSame(f, f.fork()); |
289 |
|
Integer r = f.get(); |
290 |
|
shouldThrow(); |
291 |
|
return r; |
296 |
|
return NoResult; |
297 |
|
} |
298 |
|
}; |
299 |
< |
mainPool.invoke(a); |
299 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
300 |
|
} |
301 |
|
|
302 |
|
/** |
307 |
|
public Integer compute() { |
308 |
|
try { |
309 |
|
FailingFibTask f = new FailingFibTask(8); |
310 |
< |
f.fork(); |
310 |
> |
threadAssertSame(f, f.fork()); |
311 |
|
Integer r = f.get(5L, TimeUnit.SECONDS); |
312 |
|
shouldThrow(); |
313 |
|
return r; |
318 |
|
return NoResult; |
319 |
|
} |
320 |
|
}; |
321 |
< |
mainPool.invoke(a); |
321 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
322 |
|
} |
323 |
|
|
324 |
|
/** |
328 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
329 |
|
public Integer compute() { |
330 |
|
FailingFibTask f = new FailingFibTask(8); |
331 |
< |
f.fork(); |
331 |
> |
threadAssertSame(f, f.fork()); |
332 |
|
f.quietlyJoin(); |
333 |
|
threadAssertTrue(f.isDone()); |
334 |
|
threadAssertTrue(f.isCompletedAbnormally()); |
336 |
|
return NoResult; |
337 |
|
} |
338 |
|
}; |
339 |
< |
mainPool.invoke(a); |
339 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
340 |
|
} |
341 |
|
|
342 |
|
/** |
347 |
|
public Integer compute() { |
348 |
|
try { |
349 |
|
FibTask f = new FibTask(8); |
350 |
< |
f.cancel(true); |
350 |
> |
threadAssertTrue(f.cancel(true)); |
351 |
|
Integer r = f.invoke(); |
352 |
|
shouldThrow(); |
353 |
|
return r; |
356 |
|
return NoResult; |
357 |
|
} |
358 |
|
}; |
359 |
< |
mainPool.invoke(a); |
359 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
360 |
|
} |
361 |
|
|
362 |
|
/** |
367 |
|
public Integer compute() { |
368 |
|
try { |
369 |
|
FibTask f = new FibTask(8); |
370 |
< |
f.cancel(true); |
371 |
< |
f.fork(); |
370 |
> |
threadAssertTrue(f.cancel(true)); |
371 |
> |
threadAssertSame(f, f.fork()); |
372 |
|
Integer r = f.join(); |
373 |
|
shouldThrow(); |
374 |
|
return r; |
377 |
|
return NoResult; |
378 |
|
} |
379 |
|
}; |
380 |
< |
mainPool.invoke(a); |
380 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
381 |
|
} |
382 |
|
|
383 |
|
/** |
388 |
|
public Integer compute() { |
389 |
|
try { |
390 |
|
FibTask f = new FibTask(8); |
391 |
< |
f.cancel(true); |
392 |
< |
f.fork(); |
391 |
> |
threadAssertTrue(f.cancel(true)); |
392 |
> |
threadAssertSame(f, f.fork()); |
393 |
|
Integer r = f.get(); |
394 |
|
shouldThrow(); |
395 |
|
return r; |
400 |
|
return NoResult; |
401 |
|
} |
402 |
|
}; |
403 |
< |
mainPool.invoke(a); |
403 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
404 |
|
} |
405 |
|
|
406 |
|
/** |
411 |
|
public Integer compute() { |
412 |
|
try { |
413 |
|
FibTask f = new FibTask(8); |
414 |
< |
f.cancel(true); |
415 |
< |
f.fork(); |
414 |
> |
threadAssertTrue(f.cancel(true)); |
415 |
> |
threadAssertSame(f, f.fork()); |
416 |
|
Integer r = f.get(5L, TimeUnit.SECONDS); |
417 |
|
shouldThrow(); |
418 |
|
return r; |
423 |
|
return NoResult; |
424 |
|
} |
425 |
|
}; |
426 |
< |
mainPool.invoke(a); |
426 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
427 |
|
} |
428 |
|
|
429 |
|
/** |
433 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
434 |
|
public Integer compute() { |
435 |
|
FibTask f = new FibTask(8); |
436 |
< |
f.cancel(true); |
437 |
< |
f.fork(); |
436 |
> |
threadAssertTrue(f.cancel(true)); |
437 |
> |
threadAssertSame(f, f.fork()); |
438 |
|
f.quietlyJoin(); |
439 |
|
threadAssertTrue(f.isDone()); |
440 |
|
threadAssertTrue(f.isCompletedAbnormally()); |
442 |
|
return NoResult; |
443 |
|
} |
444 |
|
}; |
445 |
< |
mainPool.invoke(a); |
445 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
446 |
|
} |
447 |
|
|
448 |
|
/** |
449 |
|
* getPool of executing task returns its pool |
450 |
|
*/ |
451 |
|
public void testGetPool() { |
452 |
+ |
final ForkJoinPool mainPool = mainPool(); |
453 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
454 |
|
public Integer compute() { |
455 |
|
threadAssertTrue(getPool() == mainPool); |
456 |
|
return NoResult; |
457 |
|
} |
458 |
|
}; |
459 |
< |
mainPool.invoke(a); |
459 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool, a)); |
460 |
|
} |
461 |
|
|
462 |
|
/** |
469 |
|
return NoResult; |
470 |
|
} |
471 |
|
}; |
472 |
< |
a.invoke(); |
472 |
> |
assertSame(NoResult, a.invoke()); |
473 |
|
} |
474 |
|
|
475 |
|
/** |
482 |
|
return NoResult; |
483 |
|
} |
484 |
|
}; |
485 |
< |
mainPool.invoke(a); |
485 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
486 |
|
} |
487 |
|
|
488 |
|
/** |
495 |
|
return NoResult; |
496 |
|
} |
497 |
|
}; |
498 |
< |
a.invoke(); |
498 |
> |
assertSame(NoResult, a.invoke()); |
499 |
|
} |
500 |
|
|
501 |
|
/** |
502 |
< |
* setRawResult(null) succeeds |
502 |
> |
* The value set by setRawResult is returned by invoke |
503 |
|
*/ |
504 |
|
public void testSetRawResult() { |
505 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
508 |
|
return NoResult; |
509 |
|
} |
510 |
|
}; |
511 |
< |
assertEquals(a.invoke(), NoResult); |
511 |
> |
assertSame(NoResult, a.invoke()); |
512 |
|
} |
513 |
|
|
514 |
|
/** |
529 |
|
return NoResult; |
530 |
|
} |
531 |
|
}; |
532 |
< |
mainPool.invoke(a); |
532 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
533 |
|
} |
534 |
|
|
535 |
|
/** |
549 |
|
return NoResult; |
550 |
|
} |
551 |
|
}; |
552 |
< |
mainPool.invoke(a); |
552 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
553 |
|
} |
554 |
|
|
555 |
|
/** |
566 |
|
return r; |
567 |
|
} |
568 |
|
}; |
569 |
< |
mainPool.invoke(a); |
569 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
570 |
|
} |
571 |
|
|
572 |
|
/** |
585 |
|
return NoResult; |
586 |
|
} |
587 |
|
}; |
588 |
< |
mainPool.invoke(a); |
588 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
589 |
|
} |
590 |
|
|
591 |
|
/** |
601 |
|
return NoResult; |
602 |
|
} |
603 |
|
}; |
604 |
< |
mainPool.invoke(a); |
604 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
605 |
|
} |
606 |
|
|
607 |
|
/** |
623 |
|
return NoResult; |
624 |
|
} |
625 |
|
}; |
626 |
< |
mainPool.invoke(a); |
626 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
627 |
|
} |
628 |
|
|
629 |
|
/** |
649 |
|
return NoResult; |
650 |
|
} |
651 |
|
}; |
652 |
< |
mainPool.invoke(a); |
652 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
653 |
|
} |
654 |
|
|
655 |
|
|
670 |
|
return NoResult; |
671 |
|
} |
672 |
|
}; |
673 |
< |
mainPool.invoke(a); |
673 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
674 |
|
} |
675 |
|
|
676 |
|
/** |
689 |
|
return NoResult; |
690 |
|
} |
691 |
|
}; |
692 |
< |
mainPool.invoke(a); |
692 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
693 |
|
} |
694 |
|
|
695 |
|
/** |
710 |
|
return NoResult; |
711 |
|
} |
712 |
|
}; |
713 |
< |
mainPool.invoke(a); |
713 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
714 |
|
} |
715 |
|
|
716 |
|
/** |
735 |
|
return NoResult; |
736 |
|
} |
737 |
|
}; |
738 |
< |
mainPool.invoke(a); |
738 |
> |
assertSame(NoResult, testInvokeOnPool(mainPool(), a)); |
739 |
|
} |
740 |
|
|
741 |
|
/** |
746 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
747 |
|
public Integer compute() { |
748 |
|
FibTask g = new FibTask(9); |
749 |
< |
g.fork(); |
749 |
> |
threadAssertSame(g, g.fork()); |
750 |
|
FibTask f = new FibTask(8); |
751 |
< |
f.fork(); |
751 |
> |
threadAssertSame(f, f.fork()); |
752 |
|
threadAssertTrue(f.tryUnfork()); |
753 |
|
helpQuiesce(); |
754 |
|
threadAssertFalse(f.isDone()); |
756 |
|
return NoResult; |
757 |
|
} |
758 |
|
}; |
759 |
< |
singletonPool.invoke(a); |
759 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
760 |
|
} |
761 |
|
|
762 |
|
/** |
767 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
768 |
|
public Integer compute() { |
769 |
|
FibTask h = new FibTask(7); |
770 |
< |
h.fork(); |
770 |
> |
threadAssertSame(h, h.fork()); |
771 |
|
FibTask g = new FibTask(9); |
772 |
< |
g.fork(); |
772 |
> |
threadAssertSame(g, g.fork()); |
773 |
|
FibTask f = new FibTask(8); |
774 |
< |
f.fork(); |
774 |
> |
threadAssertSame(f, f.fork()); |
775 |
|
threadAssertTrue(getSurplusQueuedTaskCount() > 0); |
776 |
|
helpQuiesce(); |
777 |
|
return NoResult; |
778 |
|
} |
779 |
|
}; |
780 |
< |
singletonPool.invoke(a); |
780 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
781 |
|
} |
782 |
|
|
783 |
|
/** |
787 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
788 |
|
public Integer compute() { |
789 |
|
FibTask g = new FibTask(9); |
790 |
< |
g.fork(); |
790 |
> |
threadAssertSame(g, g.fork()); |
791 |
|
FibTask f = new FibTask(8); |
792 |
< |
f.fork(); |
792 |
> |
threadAssertSame(f, f.fork()); |
793 |
|
threadAssertTrue(peekNextLocalTask() == f); |
794 |
< |
f.join(); |
794 |
> |
threadAssertTrue(f.join() == 21); |
795 |
|
threadAssertTrue(f.isDone()); |
796 |
|
helpQuiesce(); |
797 |
|
return NoResult; |
798 |
|
} |
799 |
|
}; |
800 |
< |
singletonPool.invoke(a); |
800 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
801 |
|
} |
802 |
|
|
803 |
|
/** |
808 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
809 |
|
public Integer compute() { |
810 |
|
FibTask g = new FibTask(9); |
811 |
< |
g.fork(); |
811 |
> |
threadAssertSame(g, g.fork()); |
812 |
|
FibTask f = new FibTask(8); |
813 |
< |
f.fork(); |
813 |
> |
threadAssertSame(f, f.fork()); |
814 |
|
threadAssertTrue(pollNextLocalTask() == f); |
815 |
|
helpQuiesce(); |
816 |
|
threadAssertFalse(f.isDone()); |
817 |
|
return NoResult; |
818 |
|
} |
819 |
|
}; |
820 |
< |
singletonPool.invoke(a); |
820 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
821 |
|
} |
822 |
|
|
823 |
|
/** |
824 |
< |
* pollTask returns an unexecuted task |
805 |
< |
* without executing it |
824 |
> |
* pollTask returns an unexecuted task without executing it |
825 |
|
*/ |
826 |
|
public void testPollTask() { |
827 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
828 |
|
public Integer compute() { |
829 |
|
FibTask g = new FibTask(9); |
830 |
< |
g.fork(); |
830 |
> |
threadAssertSame(g, g.fork()); |
831 |
|
FibTask f = new FibTask(8); |
832 |
< |
f.fork(); |
832 |
> |
threadAssertSame(f, f.fork()); |
833 |
|
threadAssertTrue(pollTask() == f); |
834 |
|
helpQuiesce(); |
835 |
|
threadAssertFalse(f.isDone()); |
837 |
|
return NoResult; |
838 |
|
} |
839 |
|
}; |
840 |
< |
singletonPool.invoke(a); |
840 |
> |
assertSame(NoResult, testInvokeOnPool(singletonPool(), a)); |
841 |
|
} |
842 |
|
|
843 |
|
/** |
847 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
848 |
|
public Integer compute() { |
849 |
|
FibTask g = new FibTask(9); |
850 |
< |
g.fork(); |
850 |
> |
threadAssertSame(g, g.fork()); |
851 |
|
FibTask f = new FibTask(8); |
852 |
< |
f.fork(); |
852 |
> |
threadAssertSame(f, f.fork()); |
853 |
|
threadAssertTrue(peekNextLocalTask() == g); |
854 |
< |
f.join(); |
854 |
> |
threadAssertEquals(21, (int) f.join()); |
855 |
|
helpQuiesce(); |
856 |
|
threadAssertTrue(f.isDone()); |
857 |
|
return NoResult; |
858 |
|
} |
859 |
|
}; |
860 |
< |
asyncSingletonPool.invoke(a); |
860 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
861 |
|
} |
862 |
|
|
863 |
|
/** |
868 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
869 |
|
public Integer compute() { |
870 |
|
FibTask g = new FibTask(9); |
871 |
< |
g.fork(); |
871 |
> |
threadAssertSame(g, g.fork()); |
872 |
|
FibTask f = new FibTask(8); |
873 |
< |
f.fork(); |
873 |
> |
threadAssertSame(f, f.fork()); |
874 |
|
threadAssertTrue(pollNextLocalTask() == g); |
875 |
|
helpQuiesce(); |
876 |
|
threadAssertTrue(f.isDone()); |
878 |
|
return NoResult; |
879 |
|
} |
880 |
|
}; |
881 |
< |
asyncSingletonPool.invoke(a); |
881 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
882 |
|
} |
883 |
|
|
884 |
|
/** |
889 |
|
RecursiveTask<Integer> a = new RecursiveTask<Integer>() { |
890 |
|
public Integer compute() { |
891 |
|
FibTask g = new FibTask(9); |
892 |
< |
g.fork(); |
892 |
> |
threadAssertSame(g, g.fork()); |
893 |
|
FibTask f = new FibTask(8); |
894 |
< |
f.fork(); |
894 |
> |
threadAssertSame(f, f.fork()); |
895 |
|
threadAssertTrue(pollTask() == g); |
896 |
|
helpQuiesce(); |
897 |
|
threadAssertTrue(f.isDone()); |
899 |
|
return NoResult; |
900 |
|
} |
901 |
|
}; |
902 |
< |
asyncSingletonPool.invoke(a); |
902 |
> |
assertSame(NoResult, testInvokeOnPool(asyncSingletonPool(), a)); |
903 |
|
} |
904 |
|
|
905 |
|
} |