ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ForkJoinPool8Test.java
(Generate patch)

Comparing jsr166/src/test/tck/ForkJoinPool8Test.java (file contents):
Revision 1.13 by jsr166, Mon Jul 22 18:01:03 2013 UTC vs.
Revision 1.16 by jsr166, Mon Sep 16 00:48:00 2013 UTC

# Line 1462 | Line 1462 | public class ForkJoinPool8Test extends J
1462      }
1463  
1464      /**
1465 <     * invokeAll(collection)  throws exception if any task does
1465 >     * invokeAll(collection) throws exception if any task does
1466       */
1467      public void testAbnormalInvokeAllCollectionCC() {
1468          ForkJoinTask a = new CheckedRecursiveAction() {
# Line 1494 | Line 1494 | public class ForkJoinPool8Test extends J
1494              final long startTime = System.nanoTime();
1495              assertTrue(p.isQuiescent());
1496              ForkJoinTask a = new CheckedRecursiveAction() {
1497 <                    protected void realCompute() {
1498 <                        FibAction f = new FibAction(8);
1499 <                        assertSame(f, f.fork());
1500 <                        boolean t = ForkJoinTask.getPool().awaitQuiescence(MEDIUM_DELAY_MS, TimeUnit.SECONDS);
1501 <                        assertTrue(t);
1502 <                        while (!f.isDone()) {
1503 <                            if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1504 <                                threadFail("timed out");
1505 <                            assertFalse(p.getAsyncMode());
1506 <                            assertFalse(p.isShutdown());
1507 <                            assertFalse(p.isTerminating());
1508 <                            assertFalse(p.isTerminated());
1509 <                            Thread.yield();
1510 <                        }
1511 <                        assertFalse(p.isQuiescent());
1512 <                        assertEquals(0, ForkJoinTask.getQueuedTaskCount());
1513 <                        try {
1514 <                            assertEquals(21, f.result);
1515 <                        } catch (Throwable fail) {
1516 <                            threadFail(fail.getMessage());
1517 <                        }
1497 >                protected void realCompute() {
1498 >                    FibAction f = new FibAction(8);
1499 >                    assertSame(f, f.fork());
1500 >                    boolean t = ForkJoinTask.getPool().awaitQuiescence(MEDIUM_DELAY_MS, TimeUnit.SECONDS);
1501 >                    assertTrue(t);
1502 >                    while (!f.isDone()) {
1503 >                        if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1504 >                            threadFail("timed out");
1505 >                        assertFalse(p.getAsyncMode());
1506 >                        assertFalse(p.isShutdown());
1507 >                        assertFalse(p.isTerminating());
1508 >                        assertFalse(p.isTerminated());
1509 >                        Thread.yield();
1510 >                    }
1511 >                    assertFalse(p.isQuiescent());
1512 >                    assertEquals(0, ForkJoinTask.getQueuedTaskCount());
1513 >                    try {
1514 >                        assertEquals(21, f.result);
1515 >                    } catch (Throwable fail) {
1516 >                        threadFail(fail.getMessage());
1517                      }
1518 <                };
1518 >                }};
1519              p.execute(a);
1520              while (!a.isDone() || !p.isQuiescent()) {
1521                  if (millisElapsedSince(startTime) > LONG_DELAY_MS)
# Line 1548 | Line 1547 | public class ForkJoinPool8Test extends J
1547      public void testAwaitQuiescent2() throws Exception {
1548          final ForkJoinPool p = new ForkJoinPool();
1549          try {
1551            final long startTime = System.nanoTime();
1550              assertTrue(p.isQuiescent());
1551 <            ForkJoinTask a = new CheckedRecursiveAction() {
1552 <                    protected void realCompute() {
1553 <                        FibAction f = new FibAction(8);
1554 <                        assertSame(f, f.fork());
1555 <                        ForkJoinTask.helpQuiesce();
1556 <                        while (!f.isDone()) {
1557 <                            if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1558 <                                threadFail("timed out");
1559 <                            assertFalse(p.getAsyncMode());
1560 <                            assertFalse(p.isShutdown());
1561 <                            assertFalse(p.isTerminating());
1562 <                            assertFalse(p.isTerminated());
1563 <                            Thread.yield();
1551 >            for (;;) {
1552 >                final long startTime = System.nanoTime();
1553 >                ForkJoinTask a = new CheckedRecursiveAction() {
1554 >                        protected void realCompute() {
1555 >                            FibAction f = new FibAction(8);
1556 >                            assertSame(f, f.fork());
1557 >                            ForkJoinTask.helpQuiesce();
1558 >                            while (!f.isDone()) {
1559 >                                if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1560 >                                    threadFail("timed out");
1561 >                                assertFalse(p.getAsyncMode());
1562 >                                assertFalse(p.isShutdown());
1563 >                                assertFalse(p.isTerminating());
1564 >                                assertFalse(p.isTerminated());
1565 >                                Thread.yield();
1566 >                            }
1567 >                            assertEquals(0, ForkJoinTask.getQueuedTaskCount());
1568 >                            try {
1569 >                                assertEquals(21, f.result);
1570 >                            } catch (Throwable fail) { System.out.println("fail " + fail.getMessage()); }
1571                          }
1572 <                        assertEquals(0, ForkJoinTask.getQueuedTaskCount());
1573 <                        try {
1574 <                            assertEquals(21, f.result);
1575 <                        } catch (Throwable fail) { System.out.println("fail " + fail.getMessage()); }
1576 <                    }
1577 <                };
1578 <            p.execute(a);
1579 <            while (!p.awaitQuiescence(LONG_DELAY_MS, MILLISECONDS)) {
1580 <                if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1581 <                    threadFail("timed out");
1572 >                    };
1573 >                p.execute(a);
1574 >                if (a.isDone() || p.isQuiescent())
1575 >                    continue; // Already done so cannot test; retry
1576 >                while (!p.awaitQuiescence(LONG_DELAY_MS, MILLISECONDS)) {
1577 >                    if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1578 >                        threadFail("timed out");
1579 >                    assertFalse(p.getAsyncMode());
1580 >                    assertFalse(p.isShutdown());
1581 >                    assertFalse(p.isTerminating());
1582 >                    assertFalse(p.isTerminated());
1583 >                    Thread.yield();
1584 >                }
1585 >                assertTrue(p.isQuiescent());
1586 >                assertTrue(a.isDone());
1587 >                assertEquals(0, p.getQueuedTaskCount());
1588                  assertFalse(p.getAsyncMode());
1589 +                assertEquals(0, p.getActiveThreadCount());
1590 +                assertEquals(0, p.getQueuedTaskCount());
1591 +                assertEquals(0, p.getQueuedSubmissionCount());
1592 +                assertFalse(p.hasQueuedSubmissions());
1593                  assertFalse(p.isShutdown());
1594                  assertFalse(p.isTerminating());
1595                  assertFalse(p.isTerminated());
1596 <                Thread.yield();
1596 >                break;
1597              }
1583            assertTrue(p.isQuiescent());
1584            assertTrue(a.isDone());
1585            assertEquals(0, p.getQueuedTaskCount());
1586            assertFalse(p.getAsyncMode());
1587            assertEquals(0, p.getActiveThreadCount());
1588            assertEquals(0, p.getQueuedTaskCount());
1589            assertEquals(0, p.getQueuedSubmissionCount());
1590            assertFalse(p.hasQueuedSubmissions());
1591            assertFalse(p.isShutdown());
1592            assertFalse(p.isTerminating());
1593            assertFalse(p.isTerminated());
1598          } finally {
1599              joinPool(p);
1600          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines