509 protected void realCompute() {
510 AsyncFib f = new AsyncFib(8);
511 assertSame(f, f.fork());
512 f.quietlyJoin();
513 assertEquals(21, f.number);
514 checkCompletedNormally(f);
515 }};
516 testInvokeOnPool(mainPool(), a);
517 }
518
519 /**
520 * helpQuiesce returns when tasks are complete.
521 * getQueuedTaskCount returns 0 when quiescent
522 */
523 public void testForkHelpQuiesce() {
524 RecursiveAction a = new CheckedRecursiveAction() {
525 protected void realCompute() {
526 AsyncFib f = new AsyncFib(8);
527 assertSame(f, f.fork());
528 helpQuiesce();
529 assertEquals(21, f.number);
530 assertEquals(0, getQueuedTaskCount());
531 checkCompletedNormally(f);
532 }};
533 testInvokeOnPool(mainPool(), a);
534 }
535
536 /**
537 * invoke task throws exception when task completes abnormally
538 */
539 public void testAbnormalInvoke() {
540 RecursiveAction a = new CheckedRecursiveAction() {
541 protected void realCompute() {
542 FailingAsyncFib f = new FailingAsyncFib(8);
543 try {
544 f.invoke();
545 shouldThrow();
546 } catch (FJException success) {
547 checkCompletedAbnormally(f, success);
548 }
|
509 protected void realCompute() {
510 AsyncFib f = new AsyncFib(8);
511 assertSame(f, f.fork());
512 f.quietlyJoin();
513 assertEquals(21, f.number);
514 checkCompletedNormally(f);
515 }};
516 testInvokeOnPool(mainPool(), a);
517 }
518
519 /**
520 * helpQuiesce returns when tasks are complete.
521 * getQueuedTaskCount returns 0 when quiescent
522 */
523 public void testForkHelpQuiesce() {
524 RecursiveAction a = new CheckedRecursiveAction() {
525 protected void realCompute() {
526 AsyncFib f = new AsyncFib(8);
527 assertSame(f, f.fork());
528 helpQuiesce();
529 while (!f.isDone()) // wait out race
530 ;
531 assertEquals(21, f.number);
532 assertEquals(0, getQueuedTaskCount());
533 checkCompletedNormally(f);
534 }};
535 testInvokeOnPool(mainPool(), a);
536 }
537
538 /**
539 * invoke task throws exception when task completes abnormally
540 */
541 public void testAbnormalInvoke() {
542 RecursiveAction a = new CheckedRecursiveAction() {
543 protected void realCompute() {
544 FailingAsyncFib f = new FailingAsyncFib(8);
545 try {
546 f.invoke();
547 shouldThrow();
548 } catch (FJException success) {
549 checkCompletedAbnormally(f, success);
550 }
|