@Override public boolean onExceptionalCompletion(Throwable ex, CountedCompleter caller){ try { for (ForkJoinTask[] ary : _tasks) for (ForkJoinTask fjt : ary) fjt.cancel(true); } catch(Throwable t){} return true; } @Override
/** * Cancels, ignoring any exceptions thrown by cancel. Used during * worker and pool shutdown. Cancel is spec'ed not to throw any * exceptions, but if it does anyway, we have no recourse during * shutdown, so guard against this case. */ static final void cancelIgnoringExceptions(ForkJoinTask<?> t) { if (t != null && t.status >= 0) { try { t.cancel(false); } catch (Throwable ignore) { } } }
/** * @throws NullPointerException {@inheritDoc} * @throws RejectedExecutionException {@inheritDoc} */ public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) { // In previous versions of this class, this method constructed // a task to run ForkJoinTask.invokeAll, but now external // invocation of multiple tasks is at least as efficient. List<ForkJoinTask<T>> fs = new ArrayList<ForkJoinTask<T>>(tasks.size()); // Workaround needed because method wasn't declared with // wildcards in return type but should have been. @SuppressWarnings({"unchecked", "rawtypes"}) List<Future<T>> futures = (List<Future<T>>) (List) fs; boolean done = false; try { for (Callable<T> t : tasks) { ForkJoinTask<T> f = new ForkJoinTask.AdaptedCallable<T>(t); doSubmit(f); fs.add(f); } for (ForkJoinTask<T> f : fs) f.quietlyJoin(); done = true; return futures; } finally { if (!done) for (ForkJoinTask<T> f : fs) f.cancel(false); } }
if (t != null) { if (ex != null) t.cancel(false); else if (t.doJoin() < NORMAL) ex = t.getException();
if (t != null) { if (ex != null) t.cancel(false); else if (t.doJoin() < NORMAL) ex = t.getException();
/** * Cancels, ignoring any exceptions thrown by cancel. Used during * worker and pool shutdown. Cancel is spec'ed not to throw any * exceptions, but if it does anyway, we have no recourse during * shutdown, so guard against this case. */ final void cancelIgnoringExceptions() { try { cancel(false); } catch (Throwable ignore) { } }
/** * Polls and cancels all submissions. Called only during termination. */ private void cancelSubmissions() { while (queueBase != queueTop) { ForkJoinTask<?> task = pollSubmission(); if (task != null) { try { task.cancel(false); } catch (Throwable ignore) { } } } }
if (t != null) { if (ex != null) t.cancel(false); else if (t.doJoin() < NORMAL && ex == null) ex = t.getException();
if (t != null) { if (ex != null) t.cancel(false); else if (t.doJoin() < NORMAL && ex == null) ex = t.getException();