spring-framework / org.springframework.scheduling.annotation / AsyncResult

AsyncResult

open class AsyncResult<V : Any> : ListenableFuture<V>

A pass-through Future handle that can be used for method signatures which are declared with a Future return type for asynchronous execution.

As of Spring 4.1, this class implements ListenableFuture, not just plain java.util.concurrent.Future, along with the corresponding support in @Async processing.

As of Spring 4.2, this class also supports passing execution exceptions back to the caller.

Author
Juergen Hoeller

Author
Rossen Stoyanchev

Since
3.0

See Also
Async#forValue(Object)#forExecutionException(Throwable)

Constructors

<init>

AsyncResult(value: V)

Create a new AsyncResult holder.

Functions

addCallback

open fun addCallback(callback: ListenableFutureCallback<in V>): Unit
open fun addCallback(successCallback: SuccessCallback<in V>, failureCallback: FailureCallback): Unit

cancel

open fun cancel(mayInterruptIfRunning: Boolean): Boolean

completable

open fun completable(): CompletableFuture<V>

forExecutionException

open static fun <V : Any> forExecutionException(ex: Throwable): ListenableFuture<V>

Create a new async result which exposes the given exception as an ExecutionException from Future#get().

forValue

open static fun <V : Any> forValue(value: V): ListenableFuture<V>

Create a new async result which exposes the given value from Future#get().

get

open fun get(): V
open fun get(timeout: Long, unit: TimeUnit): V

isCancelled

open fun isCancelled(): Boolean

isDone

open fun isDone(): Boolean