/** * Commences performing this task, awaits its completion if * necessary, and returns its result, or throws an (unchecked) * {@code RuntimeException} or {@code Error} if the underlying * computation did so. * * @return the computed result */ public final V invoke() { int s; if ((s = doInvoke() & DONE_MASK) != NORMAL) reportException(s); return getRawResult(); }
/** * Waits if necessary for the computation to complete, and then * retrieves its result. * * @return the computed result * @throws CancellationException if the computation was cancelled * @throws ExecutionException if the computation threw an * exception * @throws InterruptedException if the current thread is not a * member of a ForkJoinPool and was interrupted while waiting */ public final V get() throws InterruptedException, ExecutionException { int s = (Thread.currentThread() instanceof ForkJoinWorkerThread) ? doJoin() : externalInterruptibleAwaitDone(); Throwable ex; if ((s &= DONE_MASK) == CANCELLED) throw new CancellationException(); if (s == EXCEPTIONAL && (ex = getThrowableException()) != null) throw new ExecutionException(ex); return getRawResult(); }
/** * Returns the result of the computation when it {@link #isDone is * done}. This method differs from {@link #get()} in that * abnormal completion results in {@code RuntimeException} or * {@code Error}, not {@code ExecutionException}, and that * interrupts of the calling thread do <em>not</em> cause the * method to abruptly return by throwing {@code * InterruptedException}. * * @return the computed result */ public final V join() { int s; if ((s = doJoin() & DONE_MASK) != NORMAL) reportException(s); return getRawResult(); }
throw new ExecutionException(ex); return getRawResult();
/** * Report the result of invoke or join; called only upon * non-normal return of internal versions. */ private V reportResult() { int s; Throwable ex; if ((s = status) == CANCELLED) throw new CancellationException(); if (s == EXCEPTIONAL && (ex = getThrowableException()) != null) UNSAFE.throwException(ex); return getRawResult(); }
/** * Commences performing this task, awaits its completion if * necessary, and returns its result, or throws an (unchecked) * {@code RuntimeException} or {@code Error} if the underlying * computation did so. * * @return the computed result */ public final V invoke() { if (doInvoke() != NORMAL) return reportResult(); else return getRawResult(); }
/** * Returns the result of the computation when it {@link #isDone is * done}. This method differs from {@link #get()} in that * abnormal completion results in {@code RuntimeException} or * {@code Error}, not {@code ExecutionException}, and that * interrupts of the calling thread do <em>not</em> cause the * method to abruptly return by throwing {@code * InterruptedException}. * * @return the computed result */ public final V join() { if (doJoin() != NORMAL) return reportResult(); else return getRawResult(); }
/** * Waits if necessary for the computation to complete, and then * retrieves its result. * * @return the computed result * @throws CancellationException if the computation was cancelled * @throws ExecutionException if the computation threw an * exception * @throws InterruptedException if the current thread is not a * member of a ForkJoinPool and was interrupted while waiting */ public final V get() throws InterruptedException, ExecutionException { int s = (Thread.currentThread() instanceof ForkJoinWorkerThread) ? doJoin() : externalInterruptibleAwaitDone(0L); Throwable ex; if (s == CANCELLED) throw new CancellationException(); if (s == EXCEPTIONAL && (ex = getThrowableException()) != null) throw new ExecutionException(ex); return getRawResult(); }
throw new ExecutionException(ex); return getRawResult();