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(); |
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"); |
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 |
< |
} |
1513 |
> |
assertEquals(21, f.result); |
1514 |
|
}}; |
1515 |
|
p.execute(a); |
1516 |
|
while (!a.isDone() || !p.isQuiescent()) { |
1537 |
|
} |
1538 |
|
|
1539 |
|
/** |
1540 |
< |
* awaitQuiescent returns when pool isQuiescent() or the indicated |
1541 |
< |
* timeout elapse |
1540 |
> |
* awaitQuiescence returns when pool isQuiescent() or the indicated |
1541 |
> |
* timeout elapsed |
1542 |
|
*/ |
1543 |
< |
public void testAwaitQuiescent2() throws Exception { |
1543 |
> |
public void testAwaitQuiescence2() throws Exception { |
1544 |
|
final ForkJoinPool p = new ForkJoinPool(); |
1545 |
|
try { |
1546 |
|
assertTrue(p.isQuiescent()); |
1561 |
|
Thread.yield(); |
1562 |
|
} |
1563 |
|
assertEquals(0, ForkJoinTask.getQueuedTaskCount()); |
1564 |
< |
try { |
1569 |
< |
assertEquals(21, f.result); |
1570 |
< |
} catch (Throwable fail) { System.out.println("fail " + fail.getMessage()); } |
1564 |
> |
assertEquals(21, f.result); |
1565 |
|
}}; |
1566 |
|
p.execute(a); |
1567 |
|
if (a.isDone() || p.isQuiescent()) |