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

Comparing jsr166/src/test/tck/ForkJoinTaskTest.java (file contents):
Revision 1.8 by dl, Wed Aug 11 19:50:02 2010 UTC vs.
Revision 1.13 by jsr166, Mon Sep 13 07:26:30 2010 UTC

# Line 3 | Line 3
3   * Expert Group and released to the public domain, as explained at
4   * http://creativecommons.org/licenses/publicdomain
5   */
6 import java.util.*;
7 import java.util.concurrent.Executor;
8 import java.util.concurrent.Executors;
9 import java.util.concurrent.ExecutorService;
10 import java.util.concurrent.AbstractExecutorService;
11 import java.util.concurrent.CountDownLatch;
12 import java.util.concurrent.Callable;
13 import java.util.concurrent.Future;
6   import java.util.concurrent.ExecutionException;
7   import java.util.concurrent.CancellationException;
16 import java.util.concurrent.RejectedExecutionException;
8   import java.util.concurrent.ForkJoinPool;
9   import java.util.concurrent.ForkJoinTask;
10   import java.util.concurrent.ForkJoinWorkerThread;
11   import java.util.concurrent.RecursiveAction;
21 import java.util.concurrent.RecursiveTask;
22 import java.util.concurrent.TimeUnit;
23 import junit.framework.*;
12   import java.util.concurrent.TimeUnit;
13   import java.util.concurrent.atomic.*;
14   import java.util.*;
15 + import junit.framework.*;
16  
17   public class ForkJoinTaskTest extends JSR166TestCase {
18  
19      public static void main(String[] args) {
20 <        junit.textui.TestRunner.run (suite());
20 >        junit.textui.TestRunner.run(suite());
21      }
22 +
23      public static Test suite() {
24          return new TestSuite(ForkJoinTaskTest.class);
25      }
# Line 44 | Line 34 | public class ForkJoinTaskTest extends JS
34  
35      static final ForkJoinPool mainPool = new ForkJoinPool();
36      static final ForkJoinPool singletonPool = new ForkJoinPool(1);
37 <    static final ForkJoinPool asyncSingletonPool =
37 >    static final ForkJoinPool asyncSingletonPool =
38          new ForkJoinPool(1, ForkJoinPool.defaultForkJoinWorkerThreadFactory,
39                           null, true);
40      static final class FJException extends RuntimeException {
# Line 224 | Line 214 | public class ForkJoinTaskTest extends JS
214       * invoke returns when task completes normally.
215       * isCompletedAbnormally and isCancelled return false for normally
216       * completed tasks. getRawResult of a RecursiveAction returns null;
227     *
217       */
218      public void testInvoke() {
219          RecursiveAction a = new RecursiveAction() {
220 <                public void compute() {
221 <                    AsyncFib f = new AsyncFib(8);
222 <                    f.invoke();
223 <                    threadAssertTrue(f.number == 21);
224 <                    threadAssertTrue(f.isDone());
225 <                    threadAssertFalse(f.isCancelled());
226 <                    threadAssertFalse(f.isCompletedAbnormally());
227 <                    threadAssertTrue(f.getRawResult() == null);
228 <                }
240 <            };
220 >            public void compute() {
221 >                AsyncFib f = new AsyncFib(8);
222 >                f.invoke();
223 >                threadAssertTrue(f.number == 21);
224 >                threadAssertTrue(f.isDone());
225 >                threadAssertFalse(f.isCancelled());
226 >                threadAssertFalse(f.isCompletedAbnormally());
227 >                threadAssertTrue(f.getRawResult() == null);
228 >            }};
229          mainPool.invoke(a);
230      }
231  
# Line 248 | Line 236 | public class ForkJoinTaskTest extends JS
236       */
237      public void testQuietlyInvoke() {
238          RecursiveAction a = new RecursiveAction() {
239 <                public void compute() {
240 <                    AsyncFib f = new AsyncFib(8);
241 <                    f.quietlyInvoke();
242 <                    threadAssertTrue(f.number == 21);
243 <                    threadAssertTrue(f.isDone());
244 <                    threadAssertFalse(f.isCancelled());
245 <                    threadAssertFalse(f.isCompletedAbnormally());
246 <                    threadAssertTrue(f.getRawResult() == null);
247 <                }
260 <            };
239 >            public void compute() {
240 >                AsyncFib f = new AsyncFib(8);
241 >                f.quietlyInvoke();
242 >                threadAssertTrue(f.number == 21);
243 >                threadAssertTrue(f.isDone());
244 >                threadAssertFalse(f.isCancelled());
245 >                threadAssertFalse(f.isCompletedAbnormally());
246 >                threadAssertTrue(f.getRawResult() == null);
247 >            }};
248          mainPool.invoke(a);
249      }
250  
# Line 266 | Line 253 | public class ForkJoinTaskTest extends JS
253       */
254      public void testForkJoin() {
255          RecursiveAction a = new RecursiveAction() {
256 <                public void compute() {
257 <                    AsyncFib f = new AsyncFib(8);
258 <                    f.fork();
259 <                    f.join();
260 <                    threadAssertTrue(f.number == 21);
261 <                    threadAssertTrue(f.isDone());
262 <                    threadAssertTrue(f.getRawResult() == null);
263 <                }
277 <            };
256 >            public void compute() {
257 >                AsyncFib f = new AsyncFib(8);
258 >                f.fork();
259 >                f.join();
260 >                threadAssertTrue(f.number == 21);
261 >                threadAssertTrue(f.isDone());
262 >                threadAssertTrue(f.getRawResult() == null);
263 >            }};
264          mainPool.invoke(a);
265      }
266  
# Line 283 | Line 269 | public class ForkJoinTaskTest extends JS
269       */
270      public void testForkGet() {
271          RecursiveAction a = new RecursiveAction() {
272 <                public void compute() {
273 <                    try {
274 <                        AsyncFib f = new AsyncFib(8);
275 <                        f.fork();
276 <                        f.get();
277 <                        threadAssertTrue(f.number == 21);
278 <                        threadAssertTrue(f.isDone());
279 <                    } catch (Exception ex) {
280 <                        unexpectedException(ex);
295 <                    }
272 >            public void compute() {
273 >                try {
274 >                    AsyncFib f = new AsyncFib(8);
275 >                    f.fork();
276 >                    f.get();
277 >                    threadAssertTrue(f.number == 21);
278 >                    threadAssertTrue(f.isDone());
279 >                } catch (Exception ex) {
280 >                    unexpectedException(ex);
281                  }
282 <            };
282 >            }};
283          mainPool.invoke(a);
284      }
285  
# Line 303 | Line 288 | public class ForkJoinTaskTest extends JS
288       */
289      public void testForkTimedGet() {
290          RecursiveAction a = new RecursiveAction() {
291 <                public void compute() {
292 <                    try {
293 <                        AsyncFib f = new AsyncFib(8);
294 <                        f.fork();
295 <                        f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
296 <                        threadAssertTrue(f.number == 21);
297 <                        threadAssertTrue(f.isDone());
298 <                    } catch (Exception ex) {
299 <                        unexpectedException(ex);
315 <                    }
291 >            public void compute() {
292 >                try {
293 >                    AsyncFib f = new AsyncFib(8);
294 >                    f.fork();
295 >                    f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
296 >                    threadAssertTrue(f.number == 21);
297 >                    threadAssertTrue(f.isDone());
298 >                } catch (Exception ex) {
299 >                    unexpectedException(ex);
300                  }
301 <            };
301 >            }};
302          mainPool.invoke(a);
303      }
304  
# Line 323 | Line 307 | public class ForkJoinTaskTest extends JS
307       */
308      public void testForkTimedGetNPE() {
309          RecursiveAction a = new RecursiveAction() {
310 <                public void compute() {
311 <                    try {
312 <                        AsyncFib f = new AsyncFib(8);
313 <                        f.fork();
314 <                        f.get(5L, null);
315 <                        shouldThrow();
316 <                    } catch (NullPointerException success) {
317 <                    } catch (Exception ex) {
318 <                        unexpectedException(ex);
335 <                    }
310 >            public void compute() {
311 >                try {
312 >                    AsyncFib f = new AsyncFib(8);
313 >                    f.fork();
314 >                    f.get(5L, null);
315 >                    shouldThrow();
316 >                } catch (NullPointerException success) {
317 >                } catch (Exception ex) {
318 >                    unexpectedException(ex);
319                  }
320 <            };
320 >            }};
321          mainPool.invoke(a);
322      }
323  
# Line 343 | Line 326 | public class ForkJoinTaskTest extends JS
326       */
327      public void testForkQuietlyJoin() {
328          RecursiveAction a = new RecursiveAction() {
329 <                public void compute() {
330 <                    AsyncFib f = new AsyncFib(8);
331 <                    f.fork();
332 <                    f.quietlyJoin();
333 <                    threadAssertTrue(f.number == 21);
334 <                    threadAssertTrue(f.isDone());
335 <                }
353 <            };
329 >            public void compute() {
330 >                AsyncFib f = new AsyncFib(8);
331 >                f.fork();
332 >                f.quietlyJoin();
333 >                threadAssertTrue(f.number == 21);
334 >                threadAssertTrue(f.isDone());
335 >            }};
336          mainPool.invoke(a);
337      }
338  
# Line 361 | Line 343 | public class ForkJoinTaskTest extends JS
343       */
344      public void testForkHelpQuiesce() {
345          RecursiveAction a = new RecursiveAction() {
346 <                public void compute() {
347 <                    AsyncFib f = new AsyncFib(8);
348 <                    f.fork();
349 <                    f.helpQuiesce();
350 <                    threadAssertTrue(f.number == 21);
351 <                    threadAssertTrue(f.isDone());
352 <                    threadAssertTrue(getQueuedTaskCount() == 0);
353 <                }
372 <            };
346 >            public void compute() {
347 >                AsyncFib f = new AsyncFib(8);
348 >                f.fork();
349 >                f.helpQuiesce();
350 >                threadAssertTrue(f.number == 21);
351 >                threadAssertTrue(f.isDone());
352 >                threadAssertTrue(getQueuedTaskCount() == 0);
353 >            }};
354          mainPool.invoke(a);
355      }
356  
# Line 379 | Line 360 | public class ForkJoinTaskTest extends JS
360       */
361      public void testAbnormalInvoke() {
362          RecursiveAction a = new RecursiveAction() {
363 <                public void compute() {
364 <                    try {
365 <                        FailingAsyncFib f = new FailingAsyncFib(8);
366 <                        f.invoke();
367 <                        shouldThrow();
368 <                    } catch (FJException success) {
388 <                    }
363 >            public void compute() {
364 >                try {
365 >                    FailingAsyncFib f = new FailingAsyncFib(8);
366 >                    f.invoke();
367 >                    shouldThrow();
368 >                } catch (FJException success) {
369                  }
370 <            };
370 >            }};
371          mainPool.invoke(a);
372      }
373  
# Line 396 | Line 376 | public class ForkJoinTaskTest extends JS
376       */
377      public void testAbnormalQuietlyInvoke() {
378          RecursiveAction a = new RecursiveAction() {
379 <                public void compute() {
380 <                    FailingAsyncFib f = new FailingAsyncFib(8);
381 <                    f.quietlyInvoke();
382 <                    threadAssertTrue(f.isDone());
383 <                }
404 <            };
379 >            public void compute() {
380 >                FailingAsyncFib f = new FailingAsyncFib(8);
381 >                f.quietlyInvoke();
382 >                threadAssertTrue(f.isDone());
383 >            }};
384          mainPool.invoke(a);
385      }
386  
# Line 410 | Line 389 | public class ForkJoinTaskTest extends JS
389       */
390      public void testAbnormalForkJoin() {
391          RecursiveAction a = new RecursiveAction() {
392 <                public void compute() {
393 <                    try {
394 <                        FailingAsyncFib f = new FailingAsyncFib(8);
395 <                        f.fork();
396 <                        f.join();
397 <                        shouldThrow();
398 <                    } catch (FJException success) {
420 <                    }
392 >            public void compute() {
393 >                try {
394 >                    FailingAsyncFib f = new FailingAsyncFib(8);
395 >                    f.fork();
396 >                    f.join();
397 >                    shouldThrow();
398 >                } catch (FJException success) {
399                  }
400 <            };
400 >            }};
401          mainPool.invoke(a);
402      }
403  
# Line 428 | Line 406 | public class ForkJoinTaskTest extends JS
406       */
407      public void testAbnormalForkGet() {
408          RecursiveAction a = new RecursiveAction() {
409 <                public void compute() {
410 <                    try {
411 <                        FailingAsyncFib f = new FailingAsyncFib(8);
412 <                        f.fork();
413 <                        f.get();
414 <                        shouldThrow();
415 <                    } catch (ExecutionException success) {
416 <                    } catch (Exception ex) {
417 <                        unexpectedException(ex);
440 <                    }
409 >            public void compute() {
410 >                try {
411 >                    FailingAsyncFib f = new FailingAsyncFib(8);
412 >                    f.fork();
413 >                    f.get();
414 >                    shouldThrow();
415 >                } catch (ExecutionException success) {
416 >                } catch (Exception ex) {
417 >                    unexpectedException(ex);
418                  }
419 <            };
419 >            }};
420          mainPool.invoke(a);
421      }
422  
# Line 448 | Line 425 | public class ForkJoinTaskTest extends JS
425       */
426      public void testAbnormalForkTimedGet() {
427          RecursiveAction a = new RecursiveAction() {
428 <                public void compute() {
429 <                    try {
430 <                        FailingAsyncFib f = new FailingAsyncFib(8);
431 <                        f.fork();
432 <                        f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
433 <                        shouldThrow();
434 <                    } catch (ExecutionException success) {
435 <                    } catch (Exception ex) {
436 <                        unexpectedException(ex);
460 <                    }
428 >            public void compute() {
429 >                try {
430 >                    FailingAsyncFib f = new FailingAsyncFib(8);
431 >                    f.fork();
432 >                    f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
433 >                    shouldThrow();
434 >                } catch (ExecutionException success) {
435 >                } catch (Exception ex) {
436 >                    unexpectedException(ex);
437                  }
438 <            };
438 >            }};
439          mainPool.invoke(a);
440      }
441  
# Line 468 | Line 444 | public class ForkJoinTaskTest extends JS
444       */
445      public void testAbnormalForkQuietlyJoin() {
446          RecursiveAction a = new RecursiveAction() {
447 <                public void compute() {
448 <                    FailingAsyncFib f = new FailingAsyncFib(8);
449 <                    f.fork();
450 <                    f.quietlyJoin();
451 <                    threadAssertTrue(f.isDone());
452 <                    threadAssertTrue(f.isCompletedAbnormally());
453 <                    threadAssertTrue(f.getException() instanceof FJException);
454 <                }
479 <            };
447 >            public void compute() {
448 >                FailingAsyncFib f = new FailingAsyncFib(8);
449 >                f.fork();
450 >                f.quietlyJoin();
451 >                threadAssertTrue(f.isDone());
452 >                threadAssertTrue(f.isCompletedAbnormally());
453 >                threadAssertTrue(f.getException() instanceof FJException);
454 >            }};
455          mainPool.invoke(a);
456      }
457  
# Line 485 | Line 460 | public class ForkJoinTaskTest extends JS
460       */
461      public void testCancelledInvoke() {
462          RecursiveAction a = new RecursiveAction() {
463 <                public void compute() {
464 <                    try {
465 <                        AsyncFib f = new AsyncFib(8);
466 <                        f.cancel(true);
467 <                        f.invoke();
468 <                        shouldThrow();
469 <                    } catch (CancellationException success) {
495 <                    }
463 >            public void compute() {
464 >                try {
465 >                    AsyncFib f = new AsyncFib(8);
466 >                    f.cancel(true);
467 >                    f.invoke();
468 >                    shouldThrow();
469 >                } catch (CancellationException success) {
470                  }
471 <            };
471 >            }};
472          mainPool.invoke(a);
473      }
474  
# Line 503 | Line 477 | public class ForkJoinTaskTest extends JS
477       */
478      public void testCancelledForkJoin() {
479          RecursiveAction a = new RecursiveAction() {
480 <                public void compute() {
481 <                    try {
482 <                        AsyncFib f = new AsyncFib(8);
483 <                        f.cancel(true);
484 <                        f.fork();
485 <                        f.join();
486 <                        shouldThrow();
487 <                    } catch (CancellationException success) {
514 <                    }
480 >            public void compute() {
481 >                try {
482 >                    AsyncFib f = new AsyncFib(8);
483 >                    f.cancel(true);
484 >                    f.fork();
485 >                    f.join();
486 >                    shouldThrow();
487 >                } catch (CancellationException success) {
488                  }
489 <            };
489 >            }};
490          mainPool.invoke(a);
491      }
492  
# Line 522 | Line 495 | public class ForkJoinTaskTest extends JS
495       */
496      public void testCancelledForkGet() {
497          RecursiveAction a = new RecursiveAction() {
498 <                public void compute() {
499 <                    try {
500 <                        AsyncFib f = new AsyncFib(8);
501 <                        f.cancel(true);
502 <                        f.fork();
503 <                        f.get();
504 <                        shouldThrow();
505 <                    } catch (CancellationException success) {
506 <                    } catch (Exception ex) {
507 <                        unexpectedException(ex);
535 <                    }
498 >            public void compute() {
499 >                try {
500 >                    AsyncFib f = new AsyncFib(8);
501 >                    f.cancel(true);
502 >                    f.fork();
503 >                    f.get();
504 >                    shouldThrow();
505 >                } catch (CancellationException success) {
506 >                } catch (Exception ex) {
507 >                    unexpectedException(ex);
508                  }
509 <            };
509 >            }};
510          mainPool.invoke(a);
511      }
512  
# Line 543 | Line 515 | public class ForkJoinTaskTest extends JS
515       */
516      public void testCancelledForkTimedGet() {
517          RecursiveAction a = new RecursiveAction() {
518 <                public void compute() {
519 <                    try {
520 <                        AsyncFib f = new AsyncFib(8);
521 <                        f.cancel(true);
522 <                        f.fork();
523 <                        f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
524 <                        shouldThrow();
525 <                    } catch (CancellationException success) {
526 <                    } catch (Exception ex) {
527 <                        unexpectedException(ex);
556 <                    }
518 >            public void compute() {
519 >                try {
520 >                    AsyncFib f = new AsyncFib(8);
521 >                    f.cancel(true);
522 >                    f.fork();
523 >                    f.get(LONG_DELAY_MS, TimeUnit.MILLISECONDS);
524 >                    shouldThrow();
525 >                } catch (CancellationException success) {
526 >                } catch (Exception ex) {
527 >                    unexpectedException(ex);
528                  }
529 <            };
529 >            }};
530          mainPool.invoke(a);
531      }
532  
# Line 564 | Line 535 | public class ForkJoinTaskTest extends JS
535       */
536      public void testCancelledForkQuietlyJoin() {
537          RecursiveAction a = new RecursiveAction() {
538 <                public void compute() {
539 <                    AsyncFib f = new AsyncFib(8);
540 <                    f.cancel(true);
541 <                    f.fork();
542 <                    f.quietlyJoin();
543 <                    threadAssertTrue(f.isDone());
544 <                    threadAssertTrue(f.isCompletedAbnormally());
545 <                    threadAssertTrue(f.getException() instanceof CancellationException);
546 <                }
576 <            };
538 >            public void compute() {
539 >                AsyncFib f = new AsyncFib(8);
540 >                f.cancel(true);
541 >                f.fork();
542 >                f.quietlyJoin();
543 >                threadAssertTrue(f.isDone());
544 >                threadAssertTrue(f.isCompletedAbnormally());
545 >                threadAssertTrue(f.getException() instanceof CancellationException);
546 >            }};
547          mainPool.invoke(a);
548      }
549  
# Line 582 | Line 552 | public class ForkJoinTaskTest extends JS
552       */
553      public void testGetPool() {
554          RecursiveAction a = new RecursiveAction() {
555 <                public void compute() {
556 <                    threadAssertTrue(getPool() == mainPool);
557 <                }
588 <            };
555 >            public void compute() {
556 >                threadAssertTrue(getPool() == mainPool);
557 >            }};
558          mainPool.invoke(a);
559      }
560  
# Line 594 | Line 563 | public class ForkJoinTaskTest extends JS
563       */
564      public void testGetPool2() {
565          RecursiveAction a = new RecursiveAction() {
566 <                public void compute() {
567 <                    threadAssertTrue(getPool() == null);
568 <                }
600 <            };
566 >            public void compute() {
567 >                threadAssertTrue(getPool() == null);
568 >            }};
569          a.invoke();
570      }
571  
# Line 606 | Line 574 | public class ForkJoinTaskTest extends JS
574       */
575      public void testInForkJoinPool() {
576          RecursiveAction a = new RecursiveAction() {
577 <                public void compute() {
578 <                    threadAssertTrue(inForkJoinPool());
579 <                }
612 <            };
577 >            public void compute() {
578 >                threadAssertTrue(inForkJoinPool());
579 >            }};
580          mainPool.invoke(a);
581      }
582  
# Line 618 | Line 585 | public class ForkJoinTaskTest extends JS
585       */
586      public void testInForkJoinPool2() {
587          RecursiveAction a = new RecursiveAction() {
588 <                public void compute() {
589 <                    threadAssertTrue(!inForkJoinPool());
590 <                }
624 <            };
588 >            public void compute() {
589 >                threadAssertTrue(!inForkJoinPool());
590 >            }};
591          a.invoke();
592      }
593  
# Line 630 | Line 596 | public class ForkJoinTaskTest extends JS
596       */
597      public void testSetRawResult() {
598          RecursiveAction a = new RecursiveAction() {
599 <                public void compute() {
600 <                    setRawResult(null);
601 <                }
636 <            };
599 >            public void compute() {
600 >                setRawResult(null);
601 >            }};
602          a.invoke();
603      }
604  
# Line 642 | Line 607 | public class ForkJoinTaskTest extends JS
607       */
608      public void testCompleteExceptionally() {
609          RecursiveAction a = new RecursiveAction() {
610 <                public void compute() {
611 <                    try {
612 <                        AsyncFib f = new AsyncFib(8);
613 <                        f.completeExceptionally(new FJException());
614 <                        f.invoke();
615 <                        shouldThrow();
616 <                    } catch (FJException success) {
652 <                    }
610 >            public void compute() {
611 >                try {
612 >                    AsyncFib f = new AsyncFib(8);
613 >                    f.completeExceptionally(new FJException());
614 >                    f.invoke();
615 >                    shouldThrow();
616 >                } catch (FJException success) {
617                  }
618 <            };
618 >            }};
619          mainPool.invoke(a);
620      }
621  
# Line 660 | Line 624 | public class ForkJoinTaskTest extends JS
624       */
625      public void testInvokeAll2() {
626          RecursiveAction a = new RecursiveAction() {
627 <                public void compute() {
628 <                    AsyncFib f = new AsyncFib(8);
629 <                    AsyncFib g = new AsyncFib(9);
630 <                    invokeAll(f, g);
631 <                    threadAssertTrue(f.isDone());
632 <                    threadAssertTrue(f.number == 21);
633 <                    threadAssertTrue(g.isDone());
634 <                    threadAssertTrue(g.number == 34);
635 <                }
672 <            };
627 >            public void compute() {
628 >                AsyncFib f = new AsyncFib(8);
629 >                AsyncFib g = new AsyncFib(9);
630 >                invokeAll(f, g);
631 >                threadAssertTrue(f.isDone());
632 >                threadAssertTrue(f.number == 21);
633 >                threadAssertTrue(g.isDone());
634 >                threadAssertTrue(g.number == 34);
635 >            }};
636          mainPool.invoke(a);
637      }
638  
# Line 678 | Line 641 | public class ForkJoinTaskTest extends JS
641       */
642      public void testInvokeAll1() {
643          RecursiveAction a = new RecursiveAction() {
644 <                public void compute() {
645 <                    AsyncFib f = new AsyncFib(8);
646 <                    invokeAll(f);
647 <                    threadAssertTrue(f.isDone());
648 <                    threadAssertTrue(f.number == 21);
649 <                }
687 <            };
644 >            public void compute() {
645 >                AsyncFib f = new AsyncFib(8);
646 >                invokeAll(f);
647 >                threadAssertTrue(f.isDone());
648 >                threadAssertTrue(f.number == 21);
649 >            }};
650          mainPool.invoke(a);
651      }
652  
# Line 693 | Line 655 | public class ForkJoinTaskTest extends JS
655       */
656      public void testInvokeAll3() {
657          RecursiveAction a = new RecursiveAction() {
658 <                public void compute() {
659 <                    AsyncFib f = new AsyncFib(8);
660 <                    AsyncFib g = new AsyncFib(9);
661 <                    AsyncFib h = new AsyncFib(7);
662 <                    invokeAll(f, g, h);
663 <                    threadAssertTrue(f.isDone());
664 <                    threadAssertTrue(f.number == 21);
665 <                    threadAssertTrue(g.isDone());
666 <                    threadAssertTrue(g.number == 34);
667 <                    threadAssertTrue(h.isDone());
668 <                    threadAssertTrue(h.number == 13);
669 <                }
708 <            };
658 >            public void compute() {
659 >                AsyncFib f = new AsyncFib(8);
660 >                AsyncFib g = new AsyncFib(9);
661 >                AsyncFib h = new AsyncFib(7);
662 >                invokeAll(f, g, h);
663 >                threadAssertTrue(f.isDone());
664 >                threadAssertTrue(f.number == 21);
665 >                threadAssertTrue(g.isDone());
666 >                threadAssertTrue(g.number == 34);
667 >                threadAssertTrue(h.isDone());
668 >                threadAssertTrue(h.number == 13);
669 >            }};
670          mainPool.invoke(a);
671      }
672  
# Line 714 | Line 675 | public class ForkJoinTaskTest extends JS
675       */
676      public void testInvokeAllCollection() {
677          RecursiveAction a = new RecursiveAction() {
678 <                public void compute() {
679 <                    AsyncFib f = new AsyncFib(8);
680 <                    AsyncFib g = new AsyncFib(9);
681 <                    AsyncFib h = new AsyncFib(7);
682 <                    HashSet set = new HashSet();
683 <                    set.add(f);
684 <                    set.add(g);
685 <                    set.add(h);
686 <                    invokeAll(set);
687 <                    threadAssertTrue(f.isDone());
688 <                    threadAssertTrue(f.number == 21);
689 <                    threadAssertTrue(g.isDone());
690 <                    threadAssertTrue(g.number == 34);
691 <                    threadAssertTrue(h.isDone());
692 <                    threadAssertTrue(h.number == 13);
693 <                }
733 <            };
678 >            public void compute() {
679 >                AsyncFib f = new AsyncFib(8);
680 >                AsyncFib g = new AsyncFib(9);
681 >                AsyncFib h = new AsyncFib(7);
682 >                HashSet set = new HashSet();
683 >                set.add(f);
684 >                set.add(g);
685 >                set.add(h);
686 >                invokeAll(set);
687 >                threadAssertTrue(f.isDone());
688 >                threadAssertTrue(f.number == 21);
689 >                threadAssertTrue(g.isDone());
690 >                threadAssertTrue(g.number == 34);
691 >                threadAssertTrue(h.isDone());
692 >                threadAssertTrue(h.number == 13);
693 >            }};
694          mainPool.invoke(a);
695      }
696  
# Line 740 | Line 700 | public class ForkJoinTaskTest extends JS
700       */
701      public void testInvokeAllNPE() {
702          RecursiveAction a = new RecursiveAction() {
703 <                public void compute() {
704 <                    try {
705 <                        AsyncFib f = new AsyncFib(8);
706 <                        AsyncFib g = new AsyncFib(9);
707 <                        AsyncFib h = null;
708 <                        invokeAll(f, g, h);
709 <                        shouldThrow();
710 <                    } catch (NullPointerException success) {
751 <                    }
703 >            public void compute() {
704 >                try {
705 >                    AsyncFib f = new AsyncFib(8);
706 >                    AsyncFib g = new AsyncFib(9);
707 >                    AsyncFib h = null;
708 >                    invokeAll(f, g, h);
709 >                    shouldThrow();
710 >                } catch (NullPointerException success) {
711                  }
712 <            };
712 >            }};
713          mainPool.invoke(a);
714      }
715  
# Line 759 | Line 718 | public class ForkJoinTaskTest extends JS
718       */
719      public void testAbnormalInvokeAll2() {
720          RecursiveAction a = new RecursiveAction() {
721 <                public void compute() {
722 <                    try {
723 <                        AsyncFib f = new AsyncFib(8);
724 <                        FailingAsyncFib g = new FailingAsyncFib(9);
725 <                        invokeAll(f, g);
726 <                        shouldThrow();
727 <                    } catch (FJException success) {
769 <                    }
721 >            public void compute() {
722 >                try {
723 >                    AsyncFib f = new AsyncFib(8);
724 >                    FailingAsyncFib g = new FailingAsyncFib(9);
725 >                    invokeAll(f, g);
726 >                    shouldThrow();
727 >                } catch (FJException success) {
728                  }
729 <            };
729 >            }};
730          mainPool.invoke(a);
731      }
732  
# Line 777 | Line 735 | public class ForkJoinTaskTest extends JS
735       */
736      public void testAbnormalInvokeAll1() {
737          RecursiveAction a = new RecursiveAction() {
738 <                public void compute() {
739 <                    try {
740 <                        FailingAsyncFib g = new FailingAsyncFib(9);
741 <                        invokeAll(g);
742 <                        shouldThrow();
743 <                    } catch (FJException success) {
786 <                    }
738 >            public void compute() {
739 >                try {
740 >                    FailingAsyncFib g = new FailingAsyncFib(9);
741 >                    invokeAll(g);
742 >                    shouldThrow();
743 >                } catch (FJException success) {
744                  }
745 <            };
745 >            }};
746          mainPool.invoke(a);
747      }
748  
# Line 794 | Line 751 | public class ForkJoinTaskTest extends JS
751       */
752      public void testAbnormalInvokeAll3() {
753          RecursiveAction a = new RecursiveAction() {
754 <                public void compute() {
755 <                    try {
756 <                        AsyncFib f = new AsyncFib(8);
757 <                        FailingAsyncFib g = new FailingAsyncFib(9);
758 <                        AsyncFib h = new AsyncFib(7);
759 <                        invokeAll(f, g, h);
760 <                        shouldThrow();
761 <                    } catch (FJException success) {
805 <                    }
754 >            public void compute() {
755 >                try {
756 >                    AsyncFib f = new AsyncFib(8);
757 >                    FailingAsyncFib g = new FailingAsyncFib(9);
758 >                    AsyncFib h = new AsyncFib(7);
759 >                    invokeAll(f, g, h);
760 >                    shouldThrow();
761 >                } catch (FJException success) {
762                  }
763 <            };
763 >            }};
764          mainPool.invoke(a);
765      }
766  
# Line 813 | Line 769 | public class ForkJoinTaskTest extends JS
769       */
770      public void testAbnormalInvokeAllCollection() {
771          RecursiveAction a = new RecursiveAction() {
772 <                public void compute() {
773 <                    try {
774 <                        FailingAsyncFib f = new FailingAsyncFib(8);
775 <                        AsyncFib g = new AsyncFib(9);
776 <                        AsyncFib h = new AsyncFib(7);
777 <                        HashSet set = new HashSet();
778 <                        set.add(f);
779 <                        set.add(g);
780 <                        set.add(h);
781 <                        invokeAll(set);
782 <                        shouldThrow();
783 <                    } catch (FJException success) {
828 <                    }
772 >            public void compute() {
773 >                try {
774 >                    FailingAsyncFib f = new FailingAsyncFib(8);
775 >                    AsyncFib g = new AsyncFib(9);
776 >                    AsyncFib h = new AsyncFib(7);
777 >                    HashSet set = new HashSet();
778 >                    set.add(f);
779 >                    set.add(g);
780 >                    set.add(h);
781 >                    invokeAll(set);
782 >                    shouldThrow();
783 >                } catch (FJException success) {
784                  }
785 <            };
785 >            }};
786          mainPool.invoke(a);
787      }
788  
# Line 837 | Line 792 | public class ForkJoinTaskTest extends JS
792       */
793      public void testTryUnfork() {
794          RecursiveAction a = new RecursiveAction() {
795 <                public void compute() {
796 <                    AsyncFib g = new AsyncFib(9);
797 <                    g.fork();
798 <                    AsyncFib f = new AsyncFib(8);
799 <                    f.fork();
800 <                    threadAssertTrue(f.tryUnfork());
801 <                    helpQuiesce();
802 <                    threadAssertFalse(f.isDone());
803 <                    threadAssertTrue(g.isDone());
804 <                }
850 <            };
795 >            public void compute() {
796 >                AsyncFib g = new AsyncFib(9);
797 >                g.fork();
798 >                AsyncFib f = new AsyncFib(8);
799 >                f.fork();
800 >                threadAssertTrue(f.tryUnfork());
801 >                helpQuiesce();
802 >                threadAssertFalse(f.isDone());
803 >                threadAssertTrue(g.isDone());
804 >            }};
805          singletonPool.invoke(a);
806      }
807  
# Line 857 | Line 811 | public class ForkJoinTaskTest extends JS
811       */
812      public void testGetSurplusQueuedTaskCount() {
813          RecursiveAction a = new RecursiveAction() {
814 <                public void compute() {
815 <                    AsyncFib h = new AsyncFib(7);
816 <                    h.fork();
817 <                    AsyncFib g = new AsyncFib(9);
818 <                    g.fork();
819 <                    AsyncFib f = new AsyncFib(8);
820 <                    f.fork();
821 <                    threadAssertTrue(getSurplusQueuedTaskCount() > 0);
822 <                    helpQuiesce();
823 <                }
870 <            };
814 >            public void compute() {
815 >                AsyncFib h = new AsyncFib(7);
816 >                h.fork();
817 >                AsyncFib g = new AsyncFib(9);
818 >                g.fork();
819 >                AsyncFib f = new AsyncFib(8);
820 >                f.fork();
821 >                threadAssertTrue(getSurplusQueuedTaskCount() > 0);
822 >                helpQuiesce();
823 >            }};
824          singletonPool.invoke(a);
825      }
826  
# Line 876 | Line 829 | public class ForkJoinTaskTest extends JS
829       */
830      public void testPeekNextLocalTask() {
831          RecursiveAction a = new RecursiveAction() {
832 <                public void compute() {
833 <                    AsyncFib g = new AsyncFib(9);
834 <                    g.fork();
835 <                    AsyncFib f = new AsyncFib(8);
836 <                    f.fork();
837 <                    threadAssertTrue(peekNextLocalTask() == f);
838 <                    f.join();
839 <                    threadAssertTrue(f.isDone());
840 <                    helpQuiesce();
841 <                }
889 <            };
832 >            public void compute() {
833 >                AsyncFib g = new AsyncFib(9);
834 >                g.fork();
835 >                AsyncFib f = new AsyncFib(8);
836 >                f.fork();
837 >                threadAssertTrue(peekNextLocalTask() == f);
838 >                f.join();
839 >                threadAssertTrue(f.isDone());
840 >                helpQuiesce();
841 >            }};
842          singletonPool.invoke(a);
843      }
844  
# Line 896 | Line 848 | public class ForkJoinTaskTest extends JS
848       */
849      public void testPollNextLocalTask() {
850          RecursiveAction a = new RecursiveAction() {
851 <                public void compute() {
852 <                    AsyncFib g = new AsyncFib(9);
853 <                    g.fork();
854 <                    AsyncFib f = new AsyncFib(8);
855 <                    f.fork();
856 <                    threadAssertTrue(pollNextLocalTask() == f);
857 <                    helpQuiesce();
858 <                    threadAssertFalse(f.isDone());
859 <                }
908 <            };
851 >            public void compute() {
852 >                AsyncFib g = new AsyncFib(9);
853 >                g.fork();
854 >                AsyncFib f = new AsyncFib(8);
855 >                f.fork();
856 >                threadAssertTrue(pollNextLocalTask() == f);
857 >                helpQuiesce();
858 >                threadAssertFalse(f.isDone());
859 >            }};
860          singletonPool.invoke(a);
861      }
862  
# Line 915 | Line 866 | public class ForkJoinTaskTest extends JS
866       */
867      public void testPollTask() {
868          RecursiveAction a = new RecursiveAction() {
869 <                public void compute() {
870 <                    AsyncFib g = new AsyncFib(9);
871 <                    g.fork();
872 <                    AsyncFib f = new AsyncFib(8);
873 <                    f.fork();
874 <                    threadAssertTrue(pollTask() == f);
875 <                    helpQuiesce();
876 <                    threadAssertFalse(f.isDone());
877 <                    threadAssertTrue(g.isDone());
878 <                }
928 <            };
869 >            public void compute() {
870 >                AsyncFib g = new AsyncFib(9);
871 >                g.fork();
872 >                AsyncFib f = new AsyncFib(8);
873 >                f.fork();
874 >                threadAssertTrue(pollTask() == f);
875 >                helpQuiesce();
876 >                threadAssertFalse(f.isDone());
877 >                threadAssertTrue(g.isDone());
878 >            }};
879          singletonPool.invoke(a);
880      }
881  
# Line 934 | Line 884 | public class ForkJoinTaskTest extends JS
884       */
885      public void testPeekNextLocalTaskAsync() {
886          RecursiveAction a = new RecursiveAction() {
887 <                public void compute() {
888 <                    AsyncFib g = new AsyncFib(9);
889 <                    g.fork();
890 <                    AsyncFib f = new AsyncFib(8);
891 <                    f.fork();
892 <                    threadAssertTrue(peekNextLocalTask() == g);
893 <                    f.join();
894 <                    helpQuiesce();
895 <                    threadAssertTrue(f.isDone());
896 <                }
947 <            };
887 >            public void compute() {
888 >                AsyncFib g = new AsyncFib(9);
889 >                g.fork();
890 >                AsyncFib f = new AsyncFib(8);
891 >                f.fork();
892 >                threadAssertTrue(peekNextLocalTask() == g);
893 >                f.join();
894 >                helpQuiesce();
895 >                threadAssertTrue(f.isDone());
896 >            }};
897          asyncSingletonPool.invoke(a);
898      }
899  
# Line 954 | Line 903 | public class ForkJoinTaskTest extends JS
903       */
904      public void testPollNextLocalTaskAsync() {
905          RecursiveAction a = new RecursiveAction() {
906 <                public void compute() {
907 <                    AsyncFib g = new AsyncFib(9);
908 <                    g.fork();
909 <                    AsyncFib f = new AsyncFib(8);
910 <                    f.fork();
911 <                    threadAssertTrue(pollNextLocalTask() == g);
912 <                    helpQuiesce();
913 <                    threadAssertTrue(f.isDone());
914 <                    threadAssertFalse(g.isDone());
915 <                }
967 <            };
906 >            public void compute() {
907 >                AsyncFib g = new AsyncFib(9);
908 >                g.fork();
909 >                AsyncFib f = new AsyncFib(8);
910 >                f.fork();
911 >                threadAssertTrue(pollNextLocalTask() == g);
912 >                helpQuiesce();
913 >                threadAssertTrue(f.isDone());
914 >                threadAssertFalse(g.isDone());
915 >            }};
916          asyncSingletonPool.invoke(a);
917      }
918  
# Line 974 | Line 922 | public class ForkJoinTaskTest extends JS
922       */
923      public void testPollTaskAsync() {
924          RecursiveAction a = new RecursiveAction() {
925 <                public void compute() {
926 <                    AsyncFib g = new AsyncFib(9);
927 <                    g.fork();
928 <                    AsyncFib f = new AsyncFib(8);
929 <                    f.fork();
930 <                    threadAssertTrue(pollTask() == g);
931 <                    helpQuiesce();
932 <                    threadAssertTrue(f.isDone());
933 <                    threadAssertFalse(g.isDone());
934 <                }
987 <            };
925 >            public void compute() {
926 >                AsyncFib g = new AsyncFib(9);
927 >                g.fork();
928 >                AsyncFib f = new AsyncFib(8);
929 >                f.fork();
930 >                threadAssertTrue(pollTask() == g);
931 >                helpQuiesce();
932 >                threadAssertTrue(f.isDone());
933 >                threadAssertFalse(g.isDone());
934 >            }};
935          asyncSingletonPool.invoke(a);
936      }
937   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines