--- jsr166/src/test/tck/RecursiveActionTest.java 2009/08/04 10:13:48 1.6 +++ jsr166/src/test/tck/RecursiveActionTest.java 2009/11/17 12:31:23 1.8 @@ -72,16 +72,15 @@ public class RecursiveActionTest extends */ public void testInvoke() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.invoke(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - threadAssertFalse(f.isCancelled()); - threadAssertFalse(f.isCompletedAbnormally()); - threadAssertTrue(f.getRawResult() == null); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.invoke(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + threadAssertFalse(f.isCancelled()); + threadAssertFalse(f.isCompletedAbnormally()); + threadAssertTrue(f.getRawResult() == null); + }}; mainPool.invoke(a); } @@ -92,16 +91,15 @@ public class RecursiveActionTest extends */ public void testQuietlyInvoke() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.quietlyInvoke(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - threadAssertFalse(f.isCancelled()); - threadAssertFalse(f.isCompletedAbnormally()); - threadAssertTrue(f.getRawResult() == null); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.quietlyInvoke(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + threadAssertFalse(f.isCancelled()); + threadAssertFalse(f.isCompletedAbnormally()); + threadAssertTrue(f.getRawResult() == null); + }}; mainPool.invoke(a); } @@ -110,15 +108,14 @@ public class RecursiveActionTest extends */ public void testForkJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.fork(); - f.join(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.getRawResult() == null); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.fork(); + f.join(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.getRawResult() == null); + }}; mainPool.invoke(a); } @@ -127,18 +124,17 @@ public class RecursiveActionTest extends */ public void testForkGet() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.fork(); - f.get(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - } catch (Exception ex) { - unexpectedException(ex); - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.fork(); + f.get(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + } catch (Exception ex) { + unexpectedException(ex); } - }; + }}; mainPool.invoke(a); } @@ -147,18 +143,17 @@ public class RecursiveActionTest extends */ public void testForkTimedGet() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.fork(); - f.get(5L, TimeUnit.SECONDS); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - } catch (Exception ex) { - unexpectedException(ex); - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.fork(); + f.get(5L, TimeUnit.SECONDS); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + } catch (Exception ex) { + unexpectedException(ex); } - }; + }}; mainPool.invoke(a); } @@ -167,18 +162,17 @@ public class RecursiveActionTest extends */ public void testForkTimedGetNPE() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.fork(); - f.get(5L, null); - shouldThrow(); - } catch (NullPointerException success) { - } catch (Exception ex) { - unexpectedException(ex); - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.fork(); + f.get(5L, null); + shouldThrow(); + } catch (NullPointerException success) { + } catch (Exception ex) { + unexpectedException(ex); } - }; + }}; mainPool.invoke(a); } @@ -187,14 +181,13 @@ public class RecursiveActionTest extends */ public void testForkHelpJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.fork(); - f.helpJoin(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.fork(); + f.helpJoin(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + }}; mainPool.invoke(a); } @@ -203,14 +196,13 @@ public class RecursiveActionTest extends */ public void testForkQuietlyJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.fork(); - f.quietlyJoin(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.fork(); + f.quietlyJoin(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + }}; mainPool.invoke(a); } @@ -220,14 +212,13 @@ public class RecursiveActionTest extends */ public void testForkQuietlyHelpJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.fork(); - f.quietlyHelpJoin(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.fork(); + f.quietlyHelpJoin(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + }}; mainPool.invoke(a); } @@ -238,15 +229,14 @@ public class RecursiveActionTest extends */ public void testForkHelpQuiesce() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.fork(); - f.helpQuiesce(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - threadAssertTrue(getQueuedTaskCount() == 0); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.fork(); + f.helpQuiesce(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + threadAssertTrue(getQueuedTaskCount() == 0); + }}; mainPool.invoke(a); } @@ -256,15 +246,14 @@ public class RecursiveActionTest extends */ public void testAbnormalInvoke() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FailingFibAction f = new FailingFibAction(8); - f.invoke(); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FailingFibAction f = new FailingFibAction(8); + f.invoke(); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -273,12 +262,11 @@ public class RecursiveActionTest extends */ public void testAbnormalQuietlyInvoke() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FailingFibAction f = new FailingFibAction(8); - f.quietlyInvoke(); - threadAssertTrue(f.isDone()); - } - }; + public void compute() { + FailingFibAction f = new FailingFibAction(8); + f.quietlyInvoke(); + threadAssertTrue(f.isDone()); + }}; mainPool.invoke(a); } @@ -287,16 +275,15 @@ public class RecursiveActionTest extends */ public void testAbnormalForkJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FailingFibAction f = new FailingFibAction(8); - f.fork(); - f.join(); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FailingFibAction f = new FailingFibAction(8); + f.fork(); + f.join(); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -305,18 +292,17 @@ public class RecursiveActionTest extends */ public void testAbnormalForkGet() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FailingFibAction f = new FailingFibAction(8); - f.fork(); - f.get(); - shouldThrow(); - } catch (ExecutionException success) { - } catch (Exception ex) { - unexpectedException(ex); - } + public void compute() { + try { + FailingFibAction f = new FailingFibAction(8); + f.fork(); + f.get(); + shouldThrow(); + } catch (ExecutionException success) { + } catch (Exception ex) { + unexpectedException(ex); } - }; + }}; mainPool.invoke(a); } @@ -325,18 +311,17 @@ public class RecursiveActionTest extends */ public void testAbnormalForkTimedGet() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FailingFibAction f = new FailingFibAction(8); - f.fork(); - f.get(5L, TimeUnit.SECONDS); - shouldThrow(); - } catch (ExecutionException success) { - } catch (Exception ex) { - unexpectedException(ex); - } + public void compute() { + try { + FailingFibAction f = new FailingFibAction(8); + f.fork(); + f.get(5L, TimeUnit.SECONDS); + shouldThrow(); + } catch (ExecutionException success) { + } catch (Exception ex) { + unexpectedException(ex); } - }; + }}; mainPool.invoke(a); } @@ -345,16 +330,15 @@ public class RecursiveActionTest extends */ public void testAbnormalForkHelpJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FailingFibAction f = new FailingFibAction(8); - f.fork(); - f.helpJoin(); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FailingFibAction f = new FailingFibAction(8); + f.fork(); + f.helpJoin(); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -366,16 +350,15 @@ public class RecursiveActionTest extends */ public void testAbnormalForkQuietlyHelpJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FailingFibAction f = new FailingFibAction(8); - f.fork(); - f.quietlyHelpJoin(); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.isCompletedAbnormally()); - threadAssertFalse(f.isCancelled()); - threadAssertTrue(f.getException() instanceof FJException); - } - }; + public void compute() { + FailingFibAction f = new FailingFibAction(8); + f.fork(); + f.quietlyHelpJoin(); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.isCompletedAbnormally()); + threadAssertFalse(f.isCancelled()); + threadAssertTrue(f.getException() instanceof FJException); + }}; mainPool.invoke(a); } @@ -384,15 +367,14 @@ public class RecursiveActionTest extends */ public void testAbnormalForkQuietlyJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FailingFibAction f = new FailingFibAction(8); - f.fork(); - f.quietlyJoin(); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.isCompletedAbnormally()); - threadAssertTrue(f.getException() instanceof FJException); - } - }; + public void compute() { + FailingFibAction f = new FailingFibAction(8); + f.fork(); + f.quietlyJoin(); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.isCompletedAbnormally()); + threadAssertTrue(f.getException() instanceof FJException); + }}; mainPool.invoke(a); } @@ -401,16 +383,15 @@ public class RecursiveActionTest extends */ public void testCancelledInvoke() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.cancel(true); - f.invoke(); - shouldThrow(); - } catch (CancellationException success) { - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.cancel(true); + f.invoke(); + shouldThrow(); + } catch (CancellationException success) { } - }; + }}; mainPool.invoke(a); } @@ -419,17 +400,16 @@ public class RecursiveActionTest extends */ public void testCancelledForkJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.cancel(true); - f.fork(); - f.join(); - shouldThrow(); - } catch (CancellationException success) { - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.cancel(true); + f.fork(); + f.join(); + shouldThrow(); + } catch (CancellationException success) { } - }; + }}; mainPool.invoke(a); } @@ -438,19 +418,18 @@ public class RecursiveActionTest extends */ public void testCancelledForkGet() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.cancel(true); - f.fork(); - f.get(); - shouldThrow(); - } catch (CancellationException success) { - } catch (Exception ex) { - unexpectedException(ex); - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.cancel(true); + f.fork(); + f.get(); + shouldThrow(); + } catch (CancellationException success) { + } catch (Exception ex) { + unexpectedException(ex); } - }; + }}; mainPool.invoke(a); } @@ -459,19 +438,18 @@ public class RecursiveActionTest extends */ public void testCancelledForkTimedGet() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.cancel(true); - f.fork(); - f.get(5L, TimeUnit.SECONDS); - shouldThrow(); - } catch (CancellationException success) { - } catch (Exception ex) { - unexpectedException(ex); - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.cancel(true); + f.fork(); + f.get(5L, TimeUnit.SECONDS); + shouldThrow(); + } catch (CancellationException success) { + } catch (Exception ex) { + unexpectedException(ex); } - }; + }}; mainPool.invoke(a); } @@ -480,17 +458,16 @@ public class RecursiveActionTest extends */ public void testCancelledForkHelpJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.cancel(true); - f.fork(); - f.helpJoin(); - shouldThrow(); - } catch (CancellationException success) { - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.cancel(true); + f.fork(); + f.helpJoin(); + shouldThrow(); + } catch (CancellationException success) { } - }; + }}; mainPool.invoke(a); } @@ -502,17 +479,16 @@ public class RecursiveActionTest extends */ public void testCancelledForkQuietlyHelpJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.cancel(true); - f.fork(); - f.quietlyHelpJoin(); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.isCompletedAbnormally()); - threadAssertTrue(f.isCancelled()); - threadAssertTrue(f.getException() instanceof CancellationException); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.cancel(true); + f.fork(); + f.quietlyHelpJoin(); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.isCompletedAbnormally()); + threadAssertTrue(f.isCancelled()); + threadAssertTrue(f.getException() instanceof CancellationException); + }}; mainPool.invoke(a); } @@ -521,16 +497,15 @@ public class RecursiveActionTest extends */ public void testCancelledForkQuietlyJoin() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.cancel(true); - f.fork(); - f.quietlyJoin(); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.isCompletedAbnormally()); - threadAssertTrue(f.getException() instanceof CancellationException); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.cancel(true); + f.fork(); + f.quietlyJoin(); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.isCompletedAbnormally()); + threadAssertTrue(f.getException() instanceof CancellationException); + }}; mainPool.invoke(a); } @@ -539,10 +514,9 @@ public class RecursiveActionTest extends */ public void testGetPool() { RecursiveAction a = new RecursiveAction() { - public void compute() { - threadAssertTrue(getPool() == mainPool); - } - }; + public void compute() { + threadAssertTrue(getPool() == mainPool); + }}; mainPool.invoke(a); } @@ -551,10 +525,9 @@ public class RecursiveActionTest extends */ public void testGetPool2() { RecursiveAction a = new RecursiveAction() { - public void compute() { - threadAssertTrue(getPool() == null); - } - }; + public void compute() { + threadAssertTrue(getPool() == null); + }}; a.invoke(); } @@ -563,10 +536,9 @@ public class RecursiveActionTest extends */ public void testInForkJoinPool() { RecursiveAction a = new RecursiveAction() { - public void compute() { - threadAssertTrue(inForkJoinPool()); - } - }; + public void compute() { + threadAssertTrue(inForkJoinPool()); + }}; mainPool.invoke(a); } @@ -575,10 +547,9 @@ public class RecursiveActionTest extends */ public void testInForkJoinPool2() { RecursiveAction a = new RecursiveAction() { - public void compute() { - threadAssertTrue(!inForkJoinPool()); - } - }; + public void compute() { + threadAssertTrue(!inForkJoinPool()); + }}; a.invoke(); } @@ -587,12 +558,11 @@ public class RecursiveActionTest extends */ public void testWorkerGetPool() { RecursiveAction a = new RecursiveAction() { - public void compute() { - ForkJoinWorkerThread w = - (ForkJoinWorkerThread)(Thread.currentThread()); - threadAssertTrue(w.getPool() == mainPool); - } - }; + public void compute() { + ForkJoinWorkerThread w = + (ForkJoinWorkerThread)(Thread.currentThread()); + threadAssertTrue(w.getPool() == mainPool); + }}; mainPool.invoke(a); } @@ -602,14 +572,13 @@ public class RecursiveActionTest extends */ public void testWorkerGetPoolIndex() { RecursiveAction a = new RecursiveAction() { - public void compute() { - ForkJoinWorkerThread w = - (ForkJoinWorkerThread)(Thread.currentThread()); - int idx = w.getPoolIndex(); - threadAssertTrue(idx >= 0); - threadAssertTrue(idx < mainPool.getPoolSize()); - } - }; + public void compute() { + ForkJoinWorkerThread w = + (ForkJoinWorkerThread)(Thread.currentThread()); + int idx = w.getPoolIndex(); + threadAssertTrue(idx >= 0); + threadAssertTrue(idx < mainPool.getPoolSize()); + }}; mainPool.invoke(a); } @@ -619,10 +588,9 @@ public class RecursiveActionTest extends */ public void testSetRawResult() { RecursiveAction a = new RecursiveAction() { - public void compute() { - setRawResult(null); - } - }; + public void compute() { + setRawResult(null); + }}; a.invoke(); } @@ -631,18 +599,17 @@ public class RecursiveActionTest extends */ public void testReinitialize() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.invoke(); - threadAssertTrue(f.result == 21); - threadAssertTrue(f.isDone()); - threadAssertFalse(f.isCancelled()); - threadAssertFalse(f.isCompletedAbnormally()); - f.reinitialize(); - f.invoke(); - threadAssertTrue(f.result == 21); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.invoke(); + threadAssertTrue(f.result == 21); + threadAssertTrue(f.isDone()); + threadAssertFalse(f.isCancelled()); + threadAssertFalse(f.isCompletedAbnormally()); + f.reinitialize(); + f.invoke(); + threadAssertTrue(f.result == 21); + }}; mainPool.invoke(a); } @@ -651,16 +618,15 @@ public class RecursiveActionTest extends */ public void testCompleteExceptionally() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - f.completeExceptionally(new FJException()); - f.invoke(); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FibAction f = new FibAction(8); + f.completeExceptionally(new FJException()); + f.invoke(); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -669,14 +635,13 @@ public class RecursiveActionTest extends */ public void testComplete() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - f.complete(null); - f.invoke(); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.result == 0); - } - }; + public void compute() { + FibAction f = new FibAction(8); + f.complete(null); + f.invoke(); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.result == 0); + }}; mainPool.invoke(a); } @@ -685,16 +650,15 @@ public class RecursiveActionTest extends */ public void testInvokeAll2() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - FibAction g = new FibAction(9); - invokeAll(f, g); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.result == 21); - threadAssertTrue(g.isDone()); - threadAssertTrue(g.result == 34); - } - }; + public void compute() { + FibAction f = new FibAction(8); + FibAction g = new FibAction(9); + invokeAll(f, g); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.result == 21); + threadAssertTrue(g.isDone()); + threadAssertTrue(g.result == 34); + }}; mainPool.invoke(a); } @@ -703,13 +667,12 @@ public class RecursiveActionTest extends */ public void testInvokeAll1() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - invokeAll(f); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.result == 21); - } - }; + public void compute() { + FibAction f = new FibAction(8); + invokeAll(f); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.result == 21); + }}; mainPool.invoke(a); } @@ -718,19 +681,18 @@ public class RecursiveActionTest extends */ public void testInvokeAll3() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - FibAction g = new FibAction(9); - FibAction h = new FibAction(7); - invokeAll(f, g, h); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.result == 21); - threadAssertTrue(g.isDone()); - threadAssertTrue(g.result == 34); - threadAssertTrue(h.isDone()); - threadAssertTrue(h.result == 13); - } - }; + public void compute() { + FibAction f = new FibAction(8); + FibAction g = new FibAction(9); + FibAction h = new FibAction(7); + invokeAll(f, g, h); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.result == 21); + threadAssertTrue(g.isDone()); + threadAssertTrue(g.result == 34); + threadAssertTrue(h.isDone()); + threadAssertTrue(h.result == 13); + }}; mainPool.invoke(a); } @@ -739,23 +701,22 @@ public class RecursiveActionTest extends */ public void testInvokeAllCollection() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction f = new FibAction(8); - FibAction g = new FibAction(9); - FibAction h = new FibAction(7); - HashSet set = new HashSet(); - set.add(f); - set.add(g); - set.add(h); - invokeAll(set); - threadAssertTrue(f.isDone()); - threadAssertTrue(f.result == 21); - threadAssertTrue(g.isDone()); - threadAssertTrue(g.result == 34); - threadAssertTrue(h.isDone()); - threadAssertTrue(h.result == 13); - } - }; + public void compute() { + FibAction f = new FibAction(8); + FibAction g = new FibAction(9); + FibAction h = new FibAction(7); + HashSet set = new HashSet(); + set.add(f); + set.add(g); + set.add(h); + invokeAll(set); + threadAssertTrue(f.isDone()); + threadAssertTrue(f.result == 21); + threadAssertTrue(g.isDone()); + threadAssertTrue(g.result == 34); + threadAssertTrue(h.isDone()); + threadAssertTrue(h.result == 13); + }}; mainPool.invoke(a); } @@ -765,17 +726,16 @@ public class RecursiveActionTest extends */ public void testInvokeAllNPE() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - FibAction g = new FibAction(9); - FibAction h = null; - invokeAll(f, g, h); - shouldThrow(); - } catch (NullPointerException success) { - } + public void compute() { + try { + FibAction f = new FibAction(8); + FibAction g = new FibAction(9); + FibAction h = null; + invokeAll(f, g, h); + shouldThrow(); + } catch (NullPointerException success) { } - }; + }}; mainPool.invoke(a); } @@ -784,16 +744,15 @@ public class RecursiveActionTest extends */ public void testAbnormalInvokeAll2() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - FailingFibAction g = new FailingFibAction(9); - invokeAll(f, g); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FibAction f = new FibAction(8); + FailingFibAction g = new FailingFibAction(9); + invokeAll(f, g); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -802,15 +761,14 @@ public class RecursiveActionTest extends */ public void testAbnormalInvokeAll1() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FailingFibAction g = new FailingFibAction(9); - invokeAll(g); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FailingFibAction g = new FailingFibAction(9); + invokeAll(g); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -819,17 +777,16 @@ public class RecursiveActionTest extends */ public void testAbnormalInvokeAll3() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FibAction f = new FibAction(8); - FailingFibAction g = new FailingFibAction(9); - FibAction h = new FibAction(7); - invokeAll(f, g, h); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FibAction f = new FibAction(8); + FailingFibAction g = new FailingFibAction(9); + FibAction h = new FibAction(7); + invokeAll(f, g, h); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -838,21 +795,20 @@ public class RecursiveActionTest extends */ public void testAbnormalInvokeAllCollection() { RecursiveAction a = new RecursiveAction() { - public void compute() { - try { - FailingFibAction f = new FailingFibAction(8); - FibAction g = new FibAction(9); - FibAction h = new FibAction(7); - HashSet set = new HashSet(); - set.add(f); - set.add(g); - set.add(h); - invokeAll(set); - shouldThrow(); - } catch (FJException success) { - } + public void compute() { + try { + FailingFibAction f = new FailingFibAction(8); + FibAction g = new FibAction(9); + FibAction h = new FibAction(7); + HashSet set = new HashSet(); + set.add(f); + set.add(g); + set.add(h); + invokeAll(set); + shouldThrow(); + } catch (FJException success) { } - }; + }}; mainPool.invoke(a); } @@ -862,17 +818,16 @@ public class RecursiveActionTest extends */ public void testTryUnfork() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(f.tryUnfork()); - helpQuiesce(); - threadAssertFalse(f.isDone()); - threadAssertTrue(g.isDone()); - } - }; + public void compute() { + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(f.tryUnfork()); + helpQuiesce(); + threadAssertFalse(f.isDone()); + threadAssertTrue(g.isDone()); + }}; singletonPool.invoke(a); } @@ -882,17 +837,16 @@ public class RecursiveActionTest extends */ public void testGetSurplusQueuedTaskCount() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction h = new FibAction(7); - h.fork(); - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(getSurplusQueuedTaskCount() > 0); - helpQuiesce(); - } - }; + public void compute() { + FibAction h = new FibAction(7); + h.fork(); + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(getSurplusQueuedTaskCount() > 0); + helpQuiesce(); + }}; singletonPool.invoke(a); } @@ -901,17 +855,16 @@ public class RecursiveActionTest extends */ public void testPeekNextLocalTask() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(peekNextLocalTask() == f); - f.join(); - threadAssertTrue(f.isDone()); - helpQuiesce(); - } - }; + public void compute() { + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(peekNextLocalTask() == f); + f.join(); + threadAssertTrue(f.isDone()); + helpQuiesce(); + }}; singletonPool.invoke(a); } @@ -921,16 +874,15 @@ public class RecursiveActionTest extends */ public void testPollNextLocalTask() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(pollNextLocalTask() == f); - helpQuiesce(); - threadAssertFalse(f.isDone()); - } - }; + public void compute() { + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(pollNextLocalTask() == f); + helpQuiesce(); + threadAssertFalse(f.isDone()); + }}; singletonPool.invoke(a); } @@ -940,17 +892,16 @@ public class RecursiveActionTest extends */ public void testPollTask() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(pollTask() == f); - helpQuiesce(); - threadAssertFalse(f.isDone()); - threadAssertTrue(g.isDone()); - } - }; + public void compute() { + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(pollTask() == f); + helpQuiesce(); + threadAssertFalse(f.isDone()); + threadAssertTrue(g.isDone()); + }}; singletonPool.invoke(a); } @@ -959,17 +910,16 @@ public class RecursiveActionTest extends */ public void testPeekNextLocalTaskAsync() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(peekNextLocalTask() == g); - f.join(); - helpQuiesce(); - threadAssertTrue(f.isDone()); - } - }; + public void compute() { + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(peekNextLocalTask() == g); + f.join(); + helpQuiesce(); + threadAssertTrue(f.isDone()); + }}; asyncSingletonPool.invoke(a); } @@ -979,17 +929,16 @@ public class RecursiveActionTest extends */ public void testPollNextLocalTaskAsync() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(pollNextLocalTask() == g); - helpQuiesce(); - threadAssertTrue(f.isDone()); - threadAssertFalse(g.isDone()); - } - }; + public void compute() { + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(pollNextLocalTask() == g); + helpQuiesce(); + threadAssertTrue(f.isDone()); + threadAssertFalse(g.isDone()); + }}; asyncSingletonPool.invoke(a); } @@ -999,17 +948,16 @@ public class RecursiveActionTest extends */ public void testPollTaskAsync() { RecursiveAction a = new RecursiveAction() { - public void compute() { - FibAction g = new FibAction(9); - g.fork(); - FibAction f = new FibAction(8); - f.fork(); - threadAssertTrue(pollTask() == g); - helpQuiesce(); - threadAssertTrue(f.isDone()); - threadAssertFalse(g.isDone()); - } - }; + public void compute() { + FibAction g = new FibAction(9); + g.fork(); + FibAction f = new FibAction(8); + f.fork(); + threadAssertTrue(pollTask() == g); + helpQuiesce(); + threadAssertTrue(f.isDone()); + threadAssertFalse(g.isDone()); + }}; asyncSingletonPool.invoke(a); }