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

Comparing jsr166/src/main/java/util/concurrent/ForkJoinPool.java (file contents):
Revision 1.357 by jsr166, Fri Jan 17 18:43:10 2020 UTC vs.
Revision 1.358 by dl, Fri Jan 17 19:01:16 2020 UTC

# Line 2656 | Line 2656 | public class ForkJoinPool extends Abstra
2656      public <T> T invokeAny(Collection<? extends Callable<T>> tasks,
2657                             long timeout, TimeUnit unit)
2658          throws InterruptedException, ExecutionException, TimeoutException {
2659 +        int par = mode & SMASK;
2660          BulkTask<T>[] fs; BulkTask<T> root;
2661          long deadline = unit.toNanos(timeout) + System.nanoTime();
2662          if ((fs = BulkTask.forkAll(tasks, true)) != null && fs.length > 0 &&
2663              (root = fs[0]) != null) {
2664              TimeoutException tex = null;
2665              try {
2666 <                root.get(deadline, TimeUnit.NANOSECONDS);
2666 >                if (par == 0) // if no workers, caller must execute
2667 >                    root.get();
2668 >                else
2669 >                    root.get(deadline, TimeUnit.NANOSECONDS);
2670              } catch (TimeoutException tx) {
2671                  tex = tx;
2672              } catch (Throwable ignore) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines