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()); |
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); |
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) { |
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) { |
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) { |
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()); |
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()); |
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) { |
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) { |
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) { |
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()); |
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) { |
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) { |
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) { |
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) { |
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()); |
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 |
|
testInvokeOnPool(mainPool, a); |
436 |
|
} |
443 |
|
public void compute() { |
444 |
|
threadAssertTrue(getPool() == null); |
445 |
|
}}; |
446 |
< |
a.invoke(); |
446 |
> |
assertNull(a.invoke()); |
447 |
|
} |
448 |
|
|
449 |
|
/** |
465 |
|
public void compute() { |
466 |
|
threadAssertTrue(!inForkJoinPool()); |
467 |
|
}}; |
468 |
< |
a.invoke(); |
468 |
> |
assertNull(a.invoke()); |
469 |
|
} |
470 |
|
|
471 |
|
/** |
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 |
|
testInvokeOnPool(mainPool(), a); |
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 |
|
}}; |
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()); |
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 |
|
}}; |
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 |
|
}}; |
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()); |
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()); |
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 |
|
}}; |
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()); |
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()); |