2653 |
|
ForkJoinTask<T> f = |
2654 |
|
new ForkJoinTask.AdaptedInterruptibleCallable<T>(t); |
2655 |
|
futures.add(f); |
2656 |
< |
if (!isSaturated()) |
2657 |
< |
externalSubmit(f); |
2658 |
< |
else if ((mode & SHUTDOWN) == 0) |
2659 |
< |
f.doExec(); |
2660 |
< |
else |
2661 |
< |
throw new RejectedExecutionException(); |
2656 |
> |
externalSubmit(f); |
2657 |
|
} |
2658 |
|
for (int i = futures.size() - 1; i >= 0; --i) |
2659 |
|
((ForkJoinTask<?>)futures.get(i)).quietlyJoin(); |
2676 |
|
ForkJoinTask<T> f = |
2677 |
|
new ForkJoinTask.AdaptedInterruptibleCallable<T>(t); |
2678 |
|
futures.add(f); |
2679 |
< |
if (!isSaturated()) |
2685 |
< |
externalSubmit(f); |
2686 |
< |
else if ((mode & SHUTDOWN) == 0) |
2687 |
< |
f.doExec(); |
2688 |
< |
else |
2689 |
< |
throw new RejectedExecutionException(); |
2679 |
> |
externalSubmit(f); |
2680 |
|
} |
2681 |
|
long startTime = System.nanoTime(), ns = nanos; |
2682 |
|
boolean timedOut = (ns < 0L); |
2709 |
|
private static final long serialVersionUID = 2838392045355241008L; |
2710 |
|
@SuppressWarnings("serial") // Conditionally serializable |
2711 |
|
volatile E result; |
2712 |
< |
final AtomicInteger count; // in case all throw |
2713 |
< |
final ForkJoinPool pool; // to check shutdown while collecting |
2714 |
< |
InvokeAnyRoot(int n, ForkJoinPool p) { pool = p; count = new AtomicInteger(n); } |
2712 |
> |
final AtomicInteger count; // in case all throw |
2713 |
> |
final ForkJoinPool pool; // to check shutdown while collecting |
2714 |
> |
InvokeAnyRoot(int n, ForkJoinPool p) { |
2715 |
> |
pool = p; |
2716 |
> |
count = new AtomicInteger(n); |
2717 |
> |
} |
2718 |
|
final void tryComplete(Callable<E> c) { // called by InvokeAnyTasks |
2719 |
|
Throwable ex = null; |
2720 |
< |
boolean failed = (c == null || isCancelled() || (pool != null && pool.mode < 0)); |
2720 |
> |
boolean failed = (c == null || isCancelled() || |
2721 |
> |
(pool != null && pool.mode < 0)); |
2722 |
|
if (!failed && !isDone()) { |
2723 |
|
try { |
2724 |
|
complete(c.call()); |
2727 |
|
failed = true; |
2728 |
|
} |
2729 |
|
} |
2730 |
< |
if ((pool != null && pool.mode < 0) || (failed && count.getAndDecrement() <= 1)) |
2730 |
> |
if ((pool != null && pool.mode < 0) || |
2731 |
> |
(failed && count.getAndDecrement() <= 1)) |
2732 |
|
trySetThrown(ex != null ? ex : new CancellationException()); |
2733 |
|
} |
2734 |
|
public final boolean exec() { return false; } // never forked |
2784 |
|
throw new NullPointerException(); |
2785 |
|
InvokeAnyTask<T> f = new InvokeAnyTask<T>(root, c); |
2786 |
|
fs.add(f); |
2787 |
< |
if (!isSaturated()) |
2793 |
< |
externalSubmit(f); |
2794 |
< |
else if ((mode & SHUTDOWN) == 0) |
2795 |
< |
f.doExec(); |
2796 |
< |
else |
2797 |
< |
throw new RejectedExecutionException(); |
2787 |
> |
externalSubmit(f); |
2788 |
|
if (root.isDone()) |
2789 |
|
break; |
2790 |
|
} |
2811 |
|
throw new NullPointerException(); |
2812 |
|
InvokeAnyTask<T> f = new InvokeAnyTask<T>(root, c); |
2813 |
|
fs.add(f); |
2814 |
< |
if (!isSaturated()) |
2825 |
< |
externalSubmit(f); |
2826 |
< |
else if ((mode & SHUTDOWN) == 0) |
2827 |
< |
f.doExec(); |
2828 |
< |
else |
2829 |
< |
throw new RejectedExecutionException(); |
2814 |
> |
externalSubmit(f); |
2815 |
|
if (root.isDone()) |
2816 |
|
break; |
2817 |
|
} |