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

Comparing jsr166/src/jsr166y/ForkJoinPool.java (file contents):
Revision 1.175 by jsr166, Sat Jan 19 20:39:43 2013 UTC vs.
Revision 1.176 by jsr166, Tue Jan 22 23:00:06 2013 UTC

# Line 2685 | Line 2685 | public class ForkJoinPool extends Abstra
2685          // In previous versions of this class, this method constructed
2686          // a task to run ForkJoinTask.invokeAll, but now external
2687          // invocation of multiple tasks is at least as efficient.
2688 <        List<ForkJoinTask<T>> fs = new ArrayList<ForkJoinTask<T>>(tasks.size());
2689 <        // Workaround needed because method wasn't declared with
2690 <        // wildcards in return type but should have been.
2691 <        @SuppressWarnings({"unchecked", "rawtypes"})
2692 <            List<Future<T>> futures = (List<Future<T>>) (List) fs;
2688 >        ArrayList<Future<T>> futures = new ArrayList<Future<T>>(tasks.size());
2689  
2690          boolean done = false;
2691          try {
2692              for (Callable<T> t : tasks) {
2693                  ForkJoinTask<T> f = new ForkJoinTask.AdaptedCallable<T>(t);
2694                  externalPush(f);
2695 <                fs.add(f);
2695 >                futures.add(f);
2696              }
2697 <            for (ForkJoinTask<T> f : fs)
2698 <                f.quietlyJoin();
2697 >            for (int i = 0, size = futures.size(); i < size; i++)
2698 >                ((ForkJoinTask<?>)futures.get(i)).quietlyJoin();
2699              done = true;
2700              return futures;
2701          } finally {
2702              if (!done)
2703 <                for (ForkJoinTask<T> f : fs)
2704 <                    f.cancel(false);
2703 >                for (int i = 0, size = futures.size(); i < size; i++)
2704 >                    futures.get(i).cancel(false);
2705          }
2706      }
2707  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines