137 |
|
* Returns the computed result, without waiting. |
138 |
|
* |
139 |
|
* <p> This method is for cases where the caller knows that the task has |
140 |
< |
* already completed successfully, for example a filter-map of a stream of |
141 |
< |
* Future objects where the filter matches tasks that completed successfully. |
140 |
> |
* already completed successfully, for example when filtering a stream |
141 |
> |
* of Future objects for the successful tasks and using a mapping |
142 |
> |
* operation to obtain a stream of results. |
143 |
|
* {@snippet lang=java : |
144 |
|
* results = futures.stream() |
145 |
|
* .filter(f -> f.state() == Future.State.SUCCESS) |
154 |
|
* @return the computed result |
155 |
|
* @throws IllegalStateException if the task has not completed or the task |
156 |
|
* did not complete with a result |
157 |
< |
* @since 99 |
157 |
> |
* @since 19 |
158 |
|
*/ |
159 |
|
default V resultNow() { |
160 |
|
if (!isDone()) |
191 |
|
* @return the exception thrown by the task |
192 |
|
* @throws IllegalStateException if the task has not completed, the task |
193 |
|
* completed normally, or the task was cancelled |
194 |
< |
* @since 99 |
194 |
> |
* @since 19 |
195 |
|
*/ |
196 |
|
default Throwable exceptionNow() { |
197 |
|
if (!isDone()) |
217 |
|
|
218 |
|
/** |
219 |
|
* Represents the computation state. |
220 |
< |
* @since 99 |
220 |
> |
* @since 19 |
221 |
|
*/ |
222 |
|
enum State { |
223 |
|
/** |
248 |
|
* The default implementation uses {@code isDone()}, {@code isCancelled()}, |
249 |
|
* and {@code get()} to determine the state. |
250 |
|
* |
251 |
< |
* @since 99 |
251 |
> |
* @since 19 |
252 |
|
*/ |
253 |
|
default State state() { |
254 |
|
if (!isDone()) |
272 |
|
} |
273 |
|
} |
274 |
|
} |
274 |
– |
|