392 |
|
|
393 |
|
/** |
394 |
|
* Returns result or throws exception using j.u.c.Future conventions. |
395 |
< |
* Only call when {@code isDone} known to be true. |
395 |
> |
* Only call when {@code isDone} known to be true or thread known |
396 |
> |
* to be interrupted. |
397 |
|
*/ |
398 |
|
private V reportFutureResult() |
399 |
|
throws InterruptedException, ExecutionException { |
529 |
|
} |
530 |
|
|
531 |
|
/** |
532 |
< |
* Returns the result of the computation when it is ready. |
532 |
> |
* Returns the result of the computation when it {@link #isDone is done}. |
533 |
|
* This method differs from {@link #get()} in that |
534 |
|
* abnormal completion results in {@code RuntimeException} or |
535 |
|
* {@code Error}, not {@code ExecutionException}. |
560 |
|
/** |
561 |
|
* Forks the given tasks, returning when {@code isDone} holds for |
562 |
|
* each task or an (unchecked) exception is encountered, in which |
563 |
< |
* case the exception is rethrown. If more than one task |
564 |
< |
* encounters an exception, then this method throws any one of |
565 |
< |
* these exceptions. The individual status of each task may be |
563 |
> |
* case the exception is rethrown. If either task encounters an |
564 |
> |
* exception, the other one may be, but is not guaranteed to be, |
565 |
> |
* cancelled. If both tasks throw an exception, then this method |
566 |
> |
* throws one of them. The individual status of each task may be |
567 |
|
* checked using {@link #getException()} and related methods. |
568 |
|
* |
569 |
|
* <p>This method may be invoked only from within {@code |
726 |
|
return (status & COMPLETION_MASK) == CANCELLED; |
727 |
|
} |
728 |
|
|
727 |
– |
/** |
728 |
– |
* Returns {@code true} if the computation performed by this task |
729 |
– |
* has completed (or has been cancelled). |
730 |
– |
* |
731 |
– |
* @return {@code true} if this computation has completed |
732 |
– |
*/ |
729 |
|
public final boolean isDone() { |
730 |
|
return status < 0; |
731 |
|
} |
732 |
|
|
737 |
– |
/** |
738 |
– |
* Returns {@code true} if this task was cancelled. |
739 |
– |
* |
740 |
– |
* @return {@code true} if this task was cancelled |
741 |
– |
*/ |
733 |
|
public final boolean isCancelled() { |
734 |
|
return (status & COMPLETION_MASK) == CANCELLED; |
735 |
|
} |
836 |
|
} |
837 |
|
|
838 |
|
/** |
839 |
< |
* Possibly executes other tasks until this task is ready, then |
840 |
< |
* returns the result of the computation. This method may be more |
841 |
< |
* efficient than {@code join}, but is only applicable when |
842 |
< |
* there are no potential dependencies between continuation of the |
843 |
< |
* current task and that of any other task that might be executed |
844 |
< |
* while helping. (This usually holds for pure divide-and-conquer |
845 |
< |
* tasks). |
839 |
> |
* Possibly executes other tasks until this task {@link #isDone is |
840 |
> |
* done}, then returns the result of the computation. This method |
841 |
> |
* may be more efficient than {@code join}, but is only applicable |
842 |
> |
* when there are no potential dependencies between continuation |
843 |
> |
* of the current task and that of any other task that might be |
844 |
> |
* executed while helping. (This usually holds for pure |
845 |
> |
* divide-and-conquer tasks). |
846 |
|
* |
847 |
|
* <p>This method may be invoked only from within {@code |
848 |
|
* ForkJoinTask} computations (as may be determined using method |
860 |
|
} |
861 |
|
|
862 |
|
/** |
863 |
< |
* Possibly executes other tasks until this task is ready. This |
864 |
< |
* method may be useful when processing collections of tasks when |
865 |
< |
* some have been cancelled or otherwise known to have aborted. |
863 |
> |
* Possibly executes other tasks until this task {@link #isDone is |
864 |
> |
* done}. This method may be useful when processing collections |
865 |
> |
* of tasks when some have been cancelled or otherwise known to |
866 |
> |
* have aborted. |
867 |
|
* |
868 |
|
* <p>This method may be invoked only from within {@code |
869 |
|
* ForkJoinTask} computations (as may be determined using method |