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.16 by jsr166, Mon Sep 16 00:48:00 2013 UTC vs.
Revision 1.19 by jsr166, Mon Sep 16 01:27:54 2013 UTC

# Line 1485 | Line 1485 | public class ForkJoinPool8Test extends J
1485      }
1486  
1487      /**
1488 <     * awaitQuiescent by a worker is equivalent in effect to
1488 >     * awaitQuiescence by a worker is equivalent in effect to
1489       * ForkJoinTask.helpQuiesce()
1490       */
1491 <    public void testAwaitQuiescent1() throws Exception {
1491 >    public void testAwaitQuiescence1() throws Exception {
1492          final ForkJoinPool p = new ForkJoinPool();
1493          try {
1494              final long startTime = System.nanoTime();
# Line 1497 | Line 1497 | public class ForkJoinPool8Test extends J
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);
1500 >                    boolean quiescent = ForkJoinTask.getPool().awaitQuiescence(MEDIUM_DELAY_MS, TimeUnit.SECONDS);
1501 >                    assertTrue(quiescent);
1502                      while (!f.isDone()) {
1503                          if (millisElapsedSince(startTime) > LONG_DELAY_MS)
1504                              threadFail("timed out");
# Line 1541 | Line 1541 | public class ForkJoinPool8Test extends J
1541      }
1542  
1543      /**
1544 <     * awaitQuiescent returns when pool isQuiescent() or the indicated
1545 <     * timeout elapse
1544 >     * awaitQuiescence returns when pool isQuiescent() or the indicated
1545 >     * timeout elapsed
1546       */
1547 <    public void testAwaitQuiescent2() throws Exception {
1547 >    public void testAwaitQuiescence2() throws Exception {
1548          final ForkJoinPool p = new ForkJoinPool();
1549          try {
1550              assertTrue(p.isQuiescent());
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()); }
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 <                    };
1567 >                        assertEquals(0, ForkJoinTask.getQueuedTaskCount());
1568 >                        try {
1569 >                            assertEquals(21, f.result);
1570 >                        } catch (Throwable fail) { System.out.println("fail " + fail.getMessage()); }
1571 >                    }};
1572                  p.execute(a);
1573                  if (a.isDone() || p.isQuiescent())
1574                      continue; // Already done so cannot test; retry

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines