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

Comparing jsr166/src/test/tck/CountedCompleterTest.java (file contents):
Revision 1.1 by dl, Thu Mar 21 00:27:10 2013 UTC vs.
Revision 1.5 by jsr166, Tue Apr 16 05:49:18 2013 UTC

# Line 33 | Line 33 | public class CountedCompleterTest extend
33          Math.max(2, Runtime.getRuntime().availableProcessors());
34  
35      /**
36 <     * Analog of CheckedRunnable for CountedCompleter
36 >     * Analog of CheckedRunnable for ForkJoinTasks
37       */
38      public abstract class CheckedFJTask extends RecursiveAction {
39          protected abstract void realCompute() throws Throwable;
# Line 217 | Line 217 | public class CountedCompleterTest extend
217          FJException() { super(); }
218      }
219  
220    static abstract class FailingCCF extends CountedCompleter {
221        int number;
222        int rnumber;
223
224        public FailingCCF(CountedCompleter parent, int n) {
225            super(parent, 1);
226            this.number = n;
227        }
228
229        public final void compute() {
230            CountedCompleter p;
231            FailingCCF f = this;
232            int n = number;
233            while (n >= 2) {
234                new RFCCF(f, n - 2).fork();
235                f = new LFCCF(f, --n);
236            }
237            f.number = n;
238            f.onCompletion(f);
239            if ((p = f.getCompleter()) != null)
240                p.tryComplete();
241            else
242                f.quietlyComplete();
243        }
244    }
245
246    static final class LFCCF extends FailingCCF {
247        public LFCCF(CountedCompleter parent, int n) {
248            super(parent, n);
249        }
250        public final void onCompletion(CountedCompleter caller) {
251            FailingCCF p = (FailingCCF)getCompleter();
252            int n = number + rnumber;
253            if (p != null)
254                p.number = n;
255            else
256                number = n;
257        }
258    }
259    static final class RFCCF extends FailingCCF {
260        public RFCCF(CountedCompleter parent, int n) {
261            super(parent, n);
262        }
263        public final void onCompletion(CountedCompleter caller) {
264            completeExceptionally(new FJException());
265        }
266    }
267
268    static abstract class CCF extends CountedCompleter {
269        int number;
270        int rnumber;
271
272        public CCF(CountedCompleter parent, int n) {
273            super(parent, 1);
274            this.number = n;
275        }
276
277        public final void compute() {
278            CountedCompleter p;
279            CCF f = this;
280            int n = number;
281            while (n >= 2) {
282                new RCCF(f, n - 2).fork();
283                f = new LCCF(f, --n);
284            }
285            f.number = n;
286            f.onCompletion(f);
287            if ((p = f.getCompleter()) != null)
288                p.tryComplete();
289            else
290                f.quietlyComplete();
291        }
292    }
293
294    static final class LCCF extends CCF {
295        public LCCF(CountedCompleter parent, int n) {
296            super(parent, n);
297        }
298        public final void onCompletion(CountedCompleter caller) {
299            CCF p = (CCF)getCompleter();
300            int n = number + rnumber;
301            if (p != null)
302                p.number = n;
303            else
304                number = n;
305        }
306    }
307    static final class RCCF extends CCF {
308        public RCCF(CountedCompleter parent, int n) {
309            super(parent, n);
310        }
311        public final void onCompletion(CountedCompleter caller) {
312            CCF p = (CCF)getCompleter();
313            int n = number + rnumber;
314            if (p != null)
315                p.rnumber = n;
316            else
317                number = n;
318        }
319    }
320
220      static final class NoopCountedCompleter extends CountedCompleter {
221          boolean post; // set true if onCompletion called
222          NoopCountedCompleter() { super(); }
# Line 329 | Line 228 | public class CountedCompleterTest extend
228      }
229  
230      /**
231 <     * A newly constructed CountedCompleter is not completed;
231 >     * A newly constructed CountedCompleter is not completed;
232       * complete() causes completion.
233       */
234      public void testComplete() {
# Line 421 | Line 320 | public class CountedCompleterTest extend
320          CountedCompleter b = new NoopCountedCompleter(a);
321          assertEquals(a, b.getCompleter());
322      }
323 <    
323 >
324      /**
325       * getRoot returns self if no parent, else parent's root
326       */
# Line 431 | Line 330 | public class CountedCompleterTest extend
330          assertEquals(a, a.getRoot());
331          assertEquals(a, b.getRoot());
332      }
333 <              
333 >
334      /**
335       * tryComplete causes completion if pending count is zero
336       */
# Line 444 | Line 343 | public class CountedCompleterTest extend
343      }
344  
345      /**
346 <     * propagateCompletion causes completion without invokein
346 >     * propagateCompletion causes completion without invoking
347       * onCompletion if pending count is zero
348       */
349      public void testPropagateCompletion() {
# Line 456 | Line 355 | public class CountedCompleterTest extend
355      }
356  
357      /**
358 <     * tryComplete decrments pending count unless zero
358 >     * tryComplete decrements pending count unless zero
359       */
360      public void testTryComplete2() {
361          NoopCountedCompleter a = new NoopCountedCompleter();
# Line 511 | Line 410 | public class CountedCompleterTest extend
410          assertTrue(a.isDone());
411          assertFalse(b.isDone());
412      }
413 <    
413 >
414 >    // Invocation tests use some interdependent task classes
415 >    // to better test propagation etc
416 >
417 >
418 >    // Version of Fibonacci with different classes for left vs right forks
419 >    abstract static class CCF extends CountedCompleter {
420 >        int number;
421 >        int rnumber;
422 >
423 >        public CCF(CountedCompleter parent, int n) {
424 >            super(parent, 1);
425 >            this.number = n;
426 >        }
427 >
428 >        public final void compute() {
429 >            CountedCompleter p;
430 >            CCF f = this;
431 >            int n = number;
432 >            while (n >= 2) {
433 >                new RCCF(f, n - 2).fork();
434 >                f = new LCCF(f, --n);
435 >            }
436 >            f.number = n;
437 >            f.onCompletion(f);
438 >            if ((p = f.getCompleter()) != null)
439 >                p.tryComplete();
440 >            else
441 >                f.quietlyComplete();
442 >        }
443 >    }
444 >
445 >    static final class LCCF extends CCF {
446 >        public LCCF(CountedCompleter parent, int n) {
447 >            super(parent, n);
448 >        }
449 >        public final void onCompletion(CountedCompleter caller) {
450 >            CCF p = (CCF)getCompleter();
451 >            int n = number + rnumber;
452 >            if (p != null)
453 >                p.number = n;
454 >            else
455 >                number = n;
456 >        }
457 >    }
458 >    static final class RCCF extends CCF {
459 >        public RCCF(CountedCompleter parent, int n) {
460 >            super(parent, n);
461 >        }
462 >        public final void onCompletion(CountedCompleter caller) {
463 >            CCF p = (CCF)getCompleter();
464 >            int n = number + rnumber;
465 >            if (p != null)
466 >                p.rnumber = n;
467 >            else
468 >                number = n;
469 >        }
470 >    }
471 >
472 >    // Version of CCF with forced failure in left completions
473 >    abstract static class FailingCCF extends CountedCompleter {
474 >        int number;
475 >        int rnumber;
476 >
477 >        public FailingCCF(CountedCompleter parent, int n) {
478 >            super(parent, 1);
479 >            this.number = n;
480 >        }
481 >
482 >        public final void compute() {
483 >            CountedCompleter p;
484 >            FailingCCF f = this;
485 >            int n = number;
486 >            while (n >= 2) {
487 >                new RFCCF(f, n - 2).fork();
488 >                f = new LFCCF(f, --n);
489 >            }
490 >            f.number = n;
491 >            f.onCompletion(f);
492 >            if ((p = f.getCompleter()) != null)
493 >                p.tryComplete();
494 >            else
495 >                f.quietlyComplete();
496 >        }
497 >    }
498 >
499 >    static final class LFCCF extends FailingCCF {
500 >        public LFCCF(CountedCompleter parent, int n) {
501 >            super(parent, n);
502 >        }
503 >        public final void onCompletion(CountedCompleter caller) {
504 >            FailingCCF p = (FailingCCF)getCompleter();
505 >            int n = number + rnumber;
506 >            if (p != null)
507 >                p.number = n;
508 >            else
509 >                number = n;
510 >        }
511 >    }
512 >    static final class RFCCF extends FailingCCF {
513 >        public RFCCF(CountedCompleter parent, int n) {
514 >            super(parent, n);
515 >        }
516 >        public final void onCompletion(CountedCompleter caller) {
517 >            completeExceptionally(new FJException());
518 >        }
519 >    }
520 >
521      /**
522       * invoke returns when task completes normally.
523       * isCompletedAbnormally and isCancelled return false for normally
524       * completed tasks; getRawResult returns null.
525       */
526      public void testInvoke() {
527 <       ForkJoinTask a =  new CheckedFJTask() {
527 >       ForkJoinTask a = new CheckedFJTask() {
528              public void realCompute() {
529                  CCF f = new LCCF(null, 8);
530                  assertNull(f.invoke());
# Line 534 | Line 540 | public class CountedCompleterTest extend
540       * completed tasks
541       */
542      public void testQuietlyInvoke() {
543 <       ForkJoinTask a =  new CheckedFJTask() {
543 >       ForkJoinTask a = new CheckedFJTask() {
544              public void realCompute() {
545                  CCF f = new LCCF(null, 8);
546                  f.quietlyInvoke();
# Line 548 | Line 554 | public class CountedCompleterTest extend
554       * join of a forked task returns when task completes
555       */
556      public void testForkJoin() {
557 <       ForkJoinTask a =  new CheckedFJTask() {
557 >       ForkJoinTask a = new CheckedFJTask() {
558              public void realCompute() {
559                  CCF f = new LCCF(null, 8);
560                  assertSame(f, f.fork());
# Line 563 | Line 569 | public class CountedCompleterTest extend
569       * get of a forked task returns when task completes
570       */
571      public void testForkGet() {
572 <       ForkJoinTask a =  new CheckedFJTask() {
572 >       ForkJoinTask a = new CheckedFJTask() {
573              public void realCompute() throws Exception {
574                  CCF f = new LCCF(null, 8);
575                  assertSame(f, f.fork());
# Line 578 | Line 584 | public class CountedCompleterTest extend
584       * timed get of a forked task returns when task completes
585       */
586      public void testForkTimedGet() {
587 <       ForkJoinTask a =  new CheckedFJTask() {
587 >       ForkJoinTask a = new CheckedFJTask() {
588              public void realCompute() throws Exception {
589                  CCF f = new LCCF(null, 8);
590                  assertSame(f, f.fork());
# Line 593 | Line 599 | public class CountedCompleterTest extend
599       * timed get with null time unit throws NPE
600       */
601      public void testForkTimedGetNPE() {
602 <       ForkJoinTask a =  new CheckedFJTask() {
602 >       ForkJoinTask a = new CheckedFJTask() {
603              public void realCompute() throws Exception {
604                  CCF f = new LCCF(null, 8);
605                  assertSame(f, f.fork());
# Line 609 | Line 615 | public class CountedCompleterTest extend
615       * quietlyJoin of a forked task returns when task completes
616       */
617      public void testForkQuietlyJoin() {
618 <       ForkJoinTask a =  new CheckedFJTask() {
618 >       ForkJoinTask a = new CheckedFJTask() {
619              public void realCompute() {
620                  CCF f = new LCCF(null, 8);
621                  assertSame(f, f.fork());
# Line 625 | Line 631 | public class CountedCompleterTest extend
631       * getQueuedTaskCount returns 0 when quiescent
632       */
633      public void testForkHelpQuiesce() {
634 <       ForkJoinTask a =  new CheckedFJTask() {
634 >       ForkJoinTask a = new CheckedFJTask() {
635              public void realCompute() {
636                  CCF f = new LCCF(null, 8);
637                  assertSame(f, f.fork());
# Line 641 | Line 647 | public class CountedCompleterTest extend
647       * invoke task throws exception when task completes abnormally
648       */
649      public void testAbnormalInvoke() {
650 <       ForkJoinTask a =  new CheckedFJTask() {
650 >       ForkJoinTask a = new CheckedFJTask() {
651              public void realCompute() {
652                  FailingCCF f = new LFCCF(null, 8);
653                  try {
# Line 658 | Line 664 | public class CountedCompleterTest extend
664       * quietlyInvoke task returns when task completes abnormally
665       */
666      public void testAbnormalQuietlyInvoke() {
667 <       ForkJoinTask a =  new CheckedFJTask() {
667 >       ForkJoinTask a = new CheckedFJTask() {
668              public void realCompute() {
669                  FailingCCF f = new LFCCF(null, 8);
670                  f.quietlyInvoke();
# Line 672 | Line 678 | public class CountedCompleterTest extend
678       * join of a forked task throws exception when task completes abnormally
679       */
680      public void testAbnormalForkJoin() {
681 <       ForkJoinTask a =  new CheckedFJTask() {
681 >       ForkJoinTask a = new CheckedFJTask() {
682              public void realCompute() {
683                  FailingCCF f = new LFCCF(null, 8);
684                  assertSame(f, f.fork());
# Line 690 | Line 696 | public class CountedCompleterTest extend
696       * get of a forked task throws exception when task completes abnormally
697       */
698      public void testAbnormalForkGet() {
699 <       ForkJoinTask a =  new CheckedFJTask() {
699 >       ForkJoinTask a = new CheckedFJTask() {
700              public void realCompute() throws Exception {
701                  FailingCCF f = new LFCCF(null, 8);
702                  assertSame(f, f.fork());
# Line 710 | Line 716 | public class CountedCompleterTest extend
716       * timed get of a forked task throws exception when task completes abnormally
717       */
718      public void testAbnormalForkTimedGet() {
719 <       ForkJoinTask a =  new CheckedFJTask() {
719 >       ForkJoinTask a = new CheckedFJTask() {
720              public void realCompute() throws Exception {
721                  FailingCCF f = new LFCCF(null, 8);
722                  assertSame(f, f.fork());
# Line 730 | Line 736 | public class CountedCompleterTest extend
736       * quietlyJoin of a forked task returns when task completes abnormally
737       */
738      public void testAbnormalForkQuietlyJoin() {
739 <       ForkJoinTask a =  new CheckedFJTask() {
739 >       ForkJoinTask a = new CheckedFJTask() {
740              public void realCompute() {
741                  FailingCCF f = new LFCCF(null, 8);
742                  assertSame(f, f.fork());
# Line 745 | Line 751 | public class CountedCompleterTest extend
751       * invoke task throws exception when task cancelled
752       */
753      public void testCancelledInvoke() {
754 <       ForkJoinTask a =  new CheckedFJTask() {
754 >       ForkJoinTask a = new CheckedFJTask() {
755              public void realCompute() {
756                  CCF f = new LCCF(null, 8);
757                  assertTrue(f.cancel(true));
# Line 763 | Line 769 | public class CountedCompleterTest extend
769       * join of a forked task throws exception when task cancelled
770       */
771      public void testCancelledForkJoin() {
772 <       ForkJoinTask a =  new CheckedFJTask() {
772 >       ForkJoinTask a = new CheckedFJTask() {
773              public void realCompute() {
774                  CCF f = new LCCF(null, 8);
775                  assertTrue(f.cancel(true));
# Line 782 | Line 788 | public class CountedCompleterTest extend
788       * get of a forked task throws exception when task cancelled
789       */
790      public void testCancelledForkGet() {
791 <       ForkJoinTask a =  new CheckedFJTask() {
791 >       ForkJoinTask a = new CheckedFJTask() {
792              public void realCompute() throws Exception {
793                  CCF f = new LCCF(null, 8);
794                  assertTrue(f.cancel(true));
# Line 801 | Line 807 | public class CountedCompleterTest extend
807       * timed get of a forked task throws exception when task cancelled
808       */
809      public void testCancelledForkTimedGet() throws Exception {
810 <       ForkJoinTask a =  new CheckedFJTask() {
810 >       ForkJoinTask a = new CheckedFJTask() {
811              public void realCompute() throws Exception {
812                  CCF f = new LCCF(null, 8);
813                  assertTrue(f.cancel(true));
# Line 820 | Line 826 | public class CountedCompleterTest extend
826       * quietlyJoin of a forked task returns when task cancelled
827       */
828      public void testCancelledForkQuietlyJoin() {
829 <       ForkJoinTask a =  new CheckedFJTask() {
829 >       ForkJoinTask a = new CheckedFJTask() {
830              public void realCompute() {
831                  CCF f = new LCCF(null, 8);
832                  assertTrue(f.cancel(true));
# Line 836 | Line 842 | public class CountedCompleterTest extend
842       */
843      public void testGetPool() {
844          final ForkJoinPool mainPool = mainPool();
845 <       ForkJoinTask a =  new CheckedFJTask() {
845 >       ForkJoinTask a = new CheckedFJTask() {
846              public void realCompute() {
847                  assertSame(mainPool, getPool());
848              }};
# Line 847 | Line 853 | public class CountedCompleterTest extend
853       * getPool of non-FJ task returns null
854       */
855      public void testGetPool2() {
856 <       ForkJoinTask a =  new CheckedFJTask() {
856 >       ForkJoinTask a = new CheckedFJTask() {
857              public void realCompute() {
858                  assertNull(getPool());
859              }};
# Line 858 | Line 864 | public class CountedCompleterTest extend
864       * inForkJoinPool of executing task returns true
865       */
866      public void testInForkJoinPool() {
867 <       ForkJoinTask a =  new CheckedFJTask() {
867 >       ForkJoinTask a = new CheckedFJTask() {
868              public void realCompute() {
869                  assertTrue(inForkJoinPool());
870              }};
# Line 869 | Line 875 | public class CountedCompleterTest extend
875       * inForkJoinPool of non-FJ task returns false
876       */
877      public void testInForkJoinPool2() {
878 <       ForkJoinTask a =  new CheckedFJTask() {
878 >       ForkJoinTask a = new CheckedFJTask() {
879              public void realCompute() {
880                  assertFalse(inForkJoinPool());
881              }};
# Line 880 | Line 886 | public class CountedCompleterTest extend
886       * setRawResult(null) succeeds
887       */
888      public void testSetRawResult() {
889 <       ForkJoinTask a =  new CheckedFJTask() {
889 >       ForkJoinTask a = new CheckedFJTask() {
890              public void realCompute() {
891                  setRawResult(null);
892                  assertNull(getRawResult());
# Line 892 | Line 898 | public class CountedCompleterTest extend
898       * invoke task throws exception after invoking completeExceptionally
899       */
900      public void testCompleteExceptionally2() {
901 <       ForkJoinTask a =  new CheckedFJTask() {
901 >       ForkJoinTask a = new CheckedFJTask() {
902              public void realCompute() {
903                  CCF f = new LCCF(null, 8);
904                  f.completeExceptionally(new FJException());
# Line 910 | Line 916 | public class CountedCompleterTest extend
916       * invokeAll(t1, t2) invokes all task arguments
917       */
918      public void testInvokeAll2() {
919 <       ForkJoinTask a =  new CheckedFJTask() {
919 >       ForkJoinTask a = new CheckedFJTask() {
920              public void realCompute() {
921                  CCF f = new LCCF(null, 8);
922                  CCF g = new LCCF(null, 9);
# Line 927 | Line 933 | public class CountedCompleterTest extend
933       * invokeAll(tasks) with 1 argument invokes task
934       */
935      public void testInvokeAll1() {
936 <       ForkJoinTask a =  new CheckedFJTask() {
936 >       ForkJoinTask a = new CheckedFJTask() {
937              public void realCompute() {
938                  CCF f = new LCCF(null, 8);
939                  invokeAll(f);
# Line 941 | Line 947 | public class CountedCompleterTest extend
947       * invokeAll(tasks) with > 2 argument invokes tasks
948       */
949      public void testInvokeAll3() {
950 <       ForkJoinTask a =  new CheckedFJTask() {
950 >       ForkJoinTask a = new CheckedFJTask() {
951              public void realCompute() {
952                  CCF f = new LCCF(null, 8);
953                  CCF g = new LCCF(null, 9);
# Line 961 | Line 967 | public class CountedCompleterTest extend
967       * invokeAll(collection) invokes all tasks in the collection
968       */
969      public void testInvokeAllCollection() {
970 <       ForkJoinTask a =  new CheckedFJTask() {
970 >       ForkJoinTask a = new CheckedFJTask() {
971              public void realCompute() {
972                  CCF f = new LCCF(null, 8);
973                  CCF g = new LCCF(null, 9);
# Line 985 | Line 991 | public class CountedCompleterTest extend
991       * invokeAll(tasks) with any null task throws NPE
992       */
993      public void testInvokeAllNPE() {
994 <       ForkJoinTask a =  new CheckedFJTask() {
994 >       ForkJoinTask a = new CheckedFJTask() {
995              public void realCompute() {
996                  CCF f = new LCCF(null, 8);
997                  CCF g = new LCCF(null, 9);
# Line 1002 | Line 1008 | public class CountedCompleterTest extend
1008       * invokeAll(t1, t2) throw exception if any task does
1009       */
1010      public void testAbnormalInvokeAll2() {
1011 <       ForkJoinTask a =  new CheckedFJTask() {
1011 >       ForkJoinTask a = new CheckedFJTask() {
1012              public void realCompute() {
1013                  CCF f = new LCCF(null, 8);
1014                  FailingCCF g = new LFCCF(null, 9);
# Line 1020 | Line 1026 | public class CountedCompleterTest extend
1026       * invokeAll(tasks) with 1 argument throws exception if task does
1027       */
1028      public void testAbnormalInvokeAll1() {
1029 <       ForkJoinTask a =  new CheckedFJTask() {
1029 >       ForkJoinTask a = new CheckedFJTask() {
1030              public void realCompute() {
1031                  FailingCCF g = new LFCCF(null, 9);
1032                  try {
# Line 1037 | Line 1043 | public class CountedCompleterTest extend
1043       * invokeAll(tasks) with > 2 argument throws exception if any task does
1044       */
1045      public void testAbnormalInvokeAll3() {
1046 <       ForkJoinTask a =  new CheckedFJTask() {
1046 >       ForkJoinTask a = new CheckedFJTask() {
1047              public void realCompute() {
1048                  CCF f = new LCCF(null, 8);
1049                  FailingCCF g = new LFCCF(null, 9);
# Line 1056 | Line 1062 | public class CountedCompleterTest extend
1062       * invokeAll(collection)  throws exception if any task does
1063       */
1064      public void testAbnormalInvokeAllCollection() {
1065 <       ForkJoinTask a =  new CheckedFJTask() {
1065 >       ForkJoinTask a = new CheckedFJTask() {
1066              public void realCompute() {
1067                  FailingCCF f = new LFCCF(null, 8);
1068                  CCF g = new LCCF(null, 9);
# Line 1080 | Line 1086 | public class CountedCompleterTest extend
1086       * and suppresses execution
1087       */
1088      public void testTryUnfork() {
1089 <       ForkJoinTask a =  new CheckedFJTask() {
1089 >       ForkJoinTask a = new CheckedFJTask() {
1090              public void realCompute() {
1091                  CCF g = new LCCF(null, 9);
1092                  assertSame(g, g.fork());
# Line 1099 | Line 1105 | public class CountedCompleterTest extend
1105       * there are more tasks than threads
1106       */
1107      public void testGetSurplusQueuedTaskCount() {
1108 <       ForkJoinTask a =  new CheckedFJTask() {
1108 >       ForkJoinTask a = new CheckedFJTask() {
1109              public void realCompute() {
1110                  CCF h = new LCCF(null, 7);
1111                  assertSame(h, h.fork());
# Line 1121 | Line 1127 | public class CountedCompleterTest extend
1127       * peekNextLocalTask returns most recent unexecuted task.
1128       */
1129      public void testPeekNextLocalTask() {
1130 <       ForkJoinTask a =  new CheckedFJTask() {
1130 >       ForkJoinTask a = new CheckedFJTask() {
1131              public void realCompute() {
1132                  CCF g = new LCCF(null, 9);
1133                  assertSame(g, g.fork());
# Line 1141 | Line 1147 | public class CountedCompleterTest extend
1147       * executing it
1148       */
1149      public void testPollNextLocalTask() {
1150 <       ForkJoinTask a =  new CheckedFJTask() {
1150 >       ForkJoinTask a = new CheckedFJTask() {
1151              public void realCompute() {
1152                  CCF g = new LCCF(null, 9);
1153                  assertSame(g, g.fork());
# Line 1160 | Line 1166 | public class CountedCompleterTest extend
1166       * pollTask returns an unexecuted task without executing it
1167       */
1168      public void testPollTask() {
1169 <       ForkJoinTask a =  new CheckedFJTask() {
1169 >       ForkJoinTask a = new CheckedFJTask() {
1170              public void realCompute() {
1171                  CCF g = new LCCF(null, 9);
1172                  assertSame(g, g.fork());
# Line 1178 | Line 1184 | public class CountedCompleterTest extend
1184       * peekNextLocalTask returns least recent unexecuted task in async mode
1185       */
1186      public void testPeekNextLocalTaskAsync() {
1187 <       ForkJoinTask a =  new CheckedFJTask() {
1187 >       ForkJoinTask a = new CheckedFJTask() {
1188              public void realCompute() {
1189                  CCF g = new LCCF(null, 9);
1190                  assertSame(g, g.fork());
# Line 1199 | Line 1205 | public class CountedCompleterTest extend
1205       * executing it, in async mode
1206       */
1207      public void testPollNextLocalTaskAsync() {
1208 <       ForkJoinTask a =  new CheckedFJTask() {
1208 >       ForkJoinTask a = new CheckedFJTask() {
1209              public void realCompute() {
1210                  CCF g = new LCCF(null, 9);
1211                  assertSame(g, g.fork());
# Line 1219 | Line 1225 | public class CountedCompleterTest extend
1225       * async mode
1226       */
1227      public void testPollTaskAsync() {
1228 <       ForkJoinTask a =  new CheckedFJTask() {
1228 >       ForkJoinTask a = new CheckedFJTask() {
1229              public void realCompute() {
1230                  CCF g = new LCCF(null, 9);
1231                  assertSame(g, g.fork());
# Line 1242 | Line 1248 | public class CountedCompleterTest extend
1248       * completed tasks; getRawResult returns null.
1249       */
1250      public void testInvokeSingleton() {
1251 <       ForkJoinTask a =  new CheckedFJTask() {
1251 >       ForkJoinTask a = new CheckedFJTask() {
1252              public void realCompute() {
1253                  CCF f = new LCCF(null, 8);
1254                  assertNull(f.invoke());
# Line 1258 | Line 1264 | public class CountedCompleterTest extend
1264       * completed tasks
1265       */
1266      public void testQuietlyInvokeSingleton() {
1267 <       ForkJoinTask a =  new CheckedFJTask() {
1267 >       ForkJoinTask a = new CheckedFJTask() {
1268              public void realCompute() {
1269                  CCF f = new LCCF(null, 8);
1270                  f.quietlyInvoke();
# Line 1272 | Line 1278 | public class CountedCompleterTest extend
1278       * join of a forked task returns when task completes
1279       */
1280      public void testForkJoinSingleton() {
1281 <       ForkJoinTask a =  new CheckedFJTask() {
1281 >       ForkJoinTask a = new CheckedFJTask() {
1282              public void realCompute() {
1283                  CCF f = new LCCF(null, 8);
1284                  assertSame(f, f.fork());
# Line 1287 | Line 1293 | public class CountedCompleterTest extend
1293       * get of a forked task returns when task completes
1294       */
1295      public void testForkGetSingleton() {
1296 <       ForkJoinTask a =  new CheckedFJTask() {
1296 >       ForkJoinTask a = new CheckedFJTask() {
1297              public void realCompute() throws Exception {
1298                  CCF f = new LCCF(null, 8);
1299                  assertSame(f, f.fork());
# Line 1302 | Line 1308 | public class CountedCompleterTest extend
1308       * timed get of a forked task returns when task completes
1309       */
1310      public void testForkTimedGetSingleton() {
1311 <       ForkJoinTask a =  new CheckedFJTask() {
1311 >       ForkJoinTask a = new CheckedFJTask() {
1312              public void realCompute() throws Exception {
1313                  CCF f = new LCCF(null, 8);
1314                  assertSame(f, f.fork());
# Line 1317 | Line 1323 | public class CountedCompleterTest extend
1323       * timed get with null time unit throws NPE
1324       */
1325      public void testForkTimedGetNPESingleton() {
1326 <       ForkJoinTask a =  new CheckedFJTask() {
1326 >       ForkJoinTask a = new CheckedFJTask() {
1327              public void realCompute() throws Exception {
1328                  CCF f = new LCCF(null, 8);
1329                  assertSame(f, f.fork());
# Line 1333 | Line 1339 | public class CountedCompleterTest extend
1339       * quietlyJoin of a forked task returns when task completes
1340       */
1341      public void testForkQuietlyJoinSingleton() {
1342 <       ForkJoinTask a =  new CheckedFJTask() {
1342 >       ForkJoinTask a = new CheckedFJTask() {
1343              public void realCompute() {
1344                  CCF f = new LCCF(null, 8);
1345                  assertSame(f, f.fork());
# Line 1349 | Line 1355 | public class CountedCompleterTest extend
1355       * getQueuedTaskCount returns 0 when quiescent
1356       */
1357      public void testForkHelpQuiesceSingleton() {
1358 <       ForkJoinTask a =  new CheckedFJTask() {
1358 >       ForkJoinTask a = new CheckedFJTask() {
1359              public void realCompute() {
1360                  CCF f = new LCCF(null, 8);
1361                  assertSame(f, f.fork());
# Line 1365 | Line 1371 | public class CountedCompleterTest extend
1371       * invoke task throws exception when task completes abnormally
1372       */
1373      public void testAbnormalInvokeSingleton() {
1374 <       ForkJoinTask a =  new CheckedFJTask() {
1374 >       ForkJoinTask a = new CheckedFJTask() {
1375              public void realCompute() {
1376                  FailingCCF f = new LFCCF(null, 8);
1377                  try {
# Line 1382 | Line 1388 | public class CountedCompleterTest extend
1388       * quietlyInvoke task returns when task completes abnormally
1389       */
1390      public void testAbnormalQuietlyInvokeSingleton() {
1391 <       ForkJoinTask a =  new CheckedFJTask() {
1391 >       ForkJoinTask a = new CheckedFJTask() {
1392              public void realCompute() {
1393                  FailingCCF f = new LFCCF(null, 8);
1394                  f.quietlyInvoke();
# Line 1396 | Line 1402 | public class CountedCompleterTest extend
1402       * join of a forked task throws exception when task completes abnormally
1403       */
1404      public void testAbnormalForkJoinSingleton() {
1405 <       ForkJoinTask a =  new CheckedFJTask() {
1405 >       ForkJoinTask a = new CheckedFJTask() {
1406              public void realCompute() {
1407                  FailingCCF f = new LFCCF(null, 8);
1408                  assertSame(f, f.fork());
# Line 1414 | Line 1420 | public class CountedCompleterTest extend
1420       * get of a forked task throws exception when task completes abnormally
1421       */
1422      public void testAbnormalForkGetSingleton() {
1423 <       ForkJoinTask a =  new CheckedFJTask() {
1423 >       ForkJoinTask a = new CheckedFJTask() {
1424              public void realCompute() throws Exception {
1425                  FailingCCF f = new LFCCF(null, 8);
1426                  assertSame(f, f.fork());
# Line 1434 | Line 1440 | public class CountedCompleterTest extend
1440       * timed get of a forked task throws exception when task completes abnormally
1441       */
1442      public void testAbnormalForkTimedGetSingleton() {
1443 <       ForkJoinTask a =  new CheckedFJTask() {
1443 >       ForkJoinTask a = new CheckedFJTask() {
1444              public void realCompute() throws Exception {
1445                  FailingCCF f = new LFCCF(null, 8);
1446                  assertSame(f, f.fork());
# Line 1454 | Line 1460 | public class CountedCompleterTest extend
1460       * quietlyJoin of a forked task returns when task completes abnormally
1461       */
1462      public void testAbnormalForkQuietlyJoinSingleton() {
1463 <       ForkJoinTask a =  new CheckedFJTask() {
1463 >       ForkJoinTask a = new CheckedFJTask() {
1464              public void realCompute() {
1465                  FailingCCF f = new LFCCF(null, 8);
1466                  assertSame(f, f.fork());
# Line 1469 | Line 1475 | public class CountedCompleterTest extend
1475       * invoke task throws exception when task cancelled
1476       */
1477      public void testCancelledInvokeSingleton() {
1478 <       ForkJoinTask a =  new CheckedFJTask() {
1478 >       ForkJoinTask a = new CheckedFJTask() {
1479              public void realCompute() {
1480                  CCF f = new LCCF(null, 8);
1481                  assertTrue(f.cancel(true));
# Line 1487 | Line 1493 | public class CountedCompleterTest extend
1493       * join of a forked task throws exception when task cancelled
1494       */
1495      public void testCancelledForkJoinSingleton() {
1496 <       ForkJoinTask a =  new CheckedFJTask() {
1496 >       ForkJoinTask a = new CheckedFJTask() {
1497              public void realCompute() {
1498                  CCF f = new LCCF(null, 8);
1499                  assertTrue(f.cancel(true));
# Line 1506 | Line 1512 | public class CountedCompleterTest extend
1512       * get of a forked task throws exception when task cancelled
1513       */
1514      public void testCancelledForkGetSingleton() {
1515 <       ForkJoinTask a =  new CheckedFJTask() {
1515 >       ForkJoinTask a = new CheckedFJTask() {
1516              public void realCompute() throws Exception {
1517                  CCF f = new LCCF(null, 8);
1518                  assertTrue(f.cancel(true));
# Line 1525 | Line 1531 | public class CountedCompleterTest extend
1531       * timed get of a forked task throws exception when task cancelled
1532       */
1533      public void testCancelledForkTimedGetSingleton() throws Exception {
1534 <       ForkJoinTask a =  new CheckedFJTask() {
1534 >       ForkJoinTask a = new CheckedFJTask() {
1535              public void realCompute() throws Exception {
1536                  CCF f = new LCCF(null, 8);
1537                  assertTrue(f.cancel(true));
# Line 1544 | Line 1550 | public class CountedCompleterTest extend
1550       * quietlyJoin of a forked task returns when task cancelled
1551       */
1552      public void testCancelledForkQuietlyJoinSingleton() {
1553 <       ForkJoinTask a =  new CheckedFJTask() {
1553 >       ForkJoinTask a = new CheckedFJTask() {
1554              public void realCompute() {
1555                  CCF f = new LCCF(null, 8);
1556                  assertTrue(f.cancel(true));
# Line 1559 | Line 1565 | public class CountedCompleterTest extend
1565       * invoke task throws exception after invoking completeExceptionally
1566       */
1567      public void testCompleteExceptionallySingleton() {
1568 <       ForkJoinTask a =  new CheckedFJTask() {
1568 >       ForkJoinTask a = new CheckedFJTask() {
1569              public void realCompute() {
1570                  CCF f = new LCCF(null, 8);
1571                  f.completeExceptionally(new FJException());
# Line 1577 | Line 1583 | public class CountedCompleterTest extend
1583       * invokeAll(t1, t2) invokes all task arguments
1584       */
1585      public void testInvokeAll2Singleton() {
1586 <       ForkJoinTask a =  new CheckedFJTask() {
1586 >       ForkJoinTask a = new CheckedFJTask() {
1587              public void realCompute() {
1588                  CCF f = new LCCF(null, 8);
1589                  CCF g = new LCCF(null, 9);
# Line 1594 | Line 1600 | public class CountedCompleterTest extend
1600       * invokeAll(tasks) with 1 argument invokes task
1601       */
1602      public void testInvokeAll1Singleton() {
1603 <       ForkJoinTask a =  new CheckedFJTask() {
1603 >       ForkJoinTask a = new CheckedFJTask() {
1604              public void realCompute() {
1605                  CCF f = new LCCF(null, 8);
1606                  invokeAll(f);
# Line 1608 | Line 1614 | public class CountedCompleterTest extend
1614       * invokeAll(tasks) with > 2 argument invokes tasks
1615       */
1616      public void testInvokeAll3Singleton() {
1617 <       ForkJoinTask a =  new CheckedFJTask() {
1617 >       ForkJoinTask a = new CheckedFJTask() {
1618              public void realCompute() {
1619                  CCF f = new LCCF(null, 8);
1620                  CCF g = new LCCF(null, 9);
# Line 1628 | Line 1634 | public class CountedCompleterTest extend
1634       * invokeAll(collection) invokes all tasks in the collection
1635       */
1636      public void testInvokeAllCollectionSingleton() {
1637 <       ForkJoinTask a =  new CheckedFJTask() {
1637 >       ForkJoinTask a = new CheckedFJTask() {
1638              public void realCompute() {
1639                  CCF f = new LCCF(null, 8);
1640                  CCF g = new LCCF(null, 9);
# Line 1652 | Line 1658 | public class CountedCompleterTest extend
1658       * invokeAll(tasks) with any null task throws NPE
1659       */
1660      public void testInvokeAllNPESingleton() {
1661 <       ForkJoinTask a =  new CheckedFJTask() {
1661 >       ForkJoinTask a = new CheckedFJTask() {
1662              public void realCompute() {
1663                  CCF f = new LCCF(null, 8);
1664                  CCF g = new LCCF(null, 9);
# Line 1669 | Line 1675 | public class CountedCompleterTest extend
1675       * invokeAll(t1, t2) throw exception if any task does
1676       */
1677      public void testAbnormalInvokeAll2Singleton() {
1678 <       ForkJoinTask a =  new CheckedFJTask() {
1678 >       ForkJoinTask a = new CheckedFJTask() {
1679              public void realCompute() {
1680                  CCF f = new LCCF(null, 8);
1681                  FailingCCF g = new LFCCF(null, 9);
# Line 1687 | Line 1693 | public class CountedCompleterTest extend
1693       * invokeAll(tasks) with 1 argument throws exception if task does
1694       */
1695      public void testAbnormalInvokeAll1Singleton() {
1696 <       ForkJoinTask a =  new CheckedFJTask() {
1696 >       ForkJoinTask a = new CheckedFJTask() {
1697              public void realCompute() {
1698                  FailingCCF g = new LFCCF(null, 9);
1699                  try {
# Line 1704 | Line 1710 | public class CountedCompleterTest extend
1710       * invokeAll(tasks) with > 2 argument throws exception if any task does
1711       */
1712      public void testAbnormalInvokeAll3Singleton() {
1713 <       ForkJoinTask a =  new CheckedFJTask() {
1713 >       ForkJoinTask a = new CheckedFJTask() {
1714              public void realCompute() {
1715                  CCF f = new LCCF(null, 8);
1716                  FailingCCF g = new LFCCF(null, 9);
# Line 1723 | Line 1729 | public class CountedCompleterTest extend
1729       * invokeAll(collection)  throws exception if any task does
1730       */
1731      public void testAbnormalInvokeAllCollectionSingleton() {
1732 <       ForkJoinTask a =  new CheckedFJTask() {
1732 >       ForkJoinTask a = new CheckedFJTask() {
1733              public void realCompute() {
1734                  FailingCCF f = new LFCCF(null, 8);
1735                  CCF g = new LCCF(null, 9);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines