Class AsyncResult<V>
java.lang.Object
com.codename1.backend.AsyncResult<V>
- All Implemented Interfaces:
Future<V>
A Future that is already complete: what an @Async method
returns from its body.
@Async
public Future build(String month) {
return AsyncResult.of(compute(month));
}
The caller never sees this object. It receives the Future of the call
itself at once, which completes with this value when the body has run --
the same arrangement as Spring's AsyncResult and
CompletableFuture.completedFuture.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancancel(boolean mayInterruptIfRunning) Stops the work if it has not started.static <V> AsyncResult<V> A result that failed withfailure, for a body that reports rather than throws.get()Waits for the work to finish and returns its result.Waits up totimeoutfor the work to finish and returns its result.booleanWhetherFuture.cancel(boolean)cancelled the work before it ran.booleanisDone()Whether the work has finished: completed, failed or cancelled.static <V> AsyncResult<V> of(V value) A result holdingvalue.
-
Method Details
-
of
A result holdingvalue. -
failed
A result that failed withfailure, for a body that reports rather than throws. -
cancel
public boolean cancel(boolean mayInterruptIfRunning) Description copied from interface:FutureStops the work if it has not started. Answers whether it was cancelled; work already running is not interrupted by the backend's executors. -
isCancelled
public boolean isCancelled()Description copied from interface:FutureWhetherFuture.cancel(boolean)cancelled the work before it ran.- Specified by:
isCancelledin interfaceFuture<V>- Returns:
- true when cancelled
-
isDone
-
get
Description copied from interface:FutureWaits for the work to finish and returns its result.- Specified by:
getin interfaceFuture<V>- Returns:
- the result
- Throws:
ExecutionException- when the work threw;Throwable.getCause()is what it threw
-
get
Description copied from interface:FutureWaits up totimeoutfor the work to finish and returns its result.- Specified by:
getin interfaceFuture<V>- Parameters:
timeout- how long to wait, inunitunit- the unit oftimeout- Returns:
- the result
- Throws:
ExecutionException- when the work threw
-