tuweni / org.apache.tuweni.concurrent / AsyncResult

AsyncResult

interface AsyncResult<T : Any!> (source)

A result that will be available at a future time.

Functions

accept

Returns a new completion that, when this result completes either normally or exceptionally, completes after executing the supplied function with this result's value and exception as arguments.

abstract fun accept(consumer: BiConsumer<in T, Throwable!>!): AsyncCompletion!

allOf

Returns an AsyncCompletion that completes when all of the given results complete. If any results complete exceptionally, then the resulting completion also completes exceptionally.

open static fun allOf(vararg rs: AsyncResult<*>!): AsyncCompletion!
open static fun allOf(rs: MutableCollection<out AsyncResult<*>!>!): AsyncCompletion!
open static fun allOf(rs: Stream<out AsyncResult<*>!>!): AsyncCompletion!

cancel

Attempt to cancel execution of this task.

abstract fun cancel(): Boolean

combine

Returns a result that completes when all of the given results complete. If any results complete exceptionally, then the resulting completion also completes exceptionally.

open static fun <T : Any!> combine(rs: MutableCollection<out AsyncResult<out T>!>!): AsyncResult<MutableList<T>!>!
open static fun <T : Any!> combine(rs: Stream<out AsyncResult<out T>!>!): AsyncResult<MutableList<T>!>!

completed

Return an already completed result containing the given value.

open static fun <T : Any!> completed(value: T?): AsyncResult<T>!

exceptional

Return an already failed result, caused by the given exception.

open static fun <T : Any!> exceptional(ex: Throwable!): AsyncResult<T>!

exceptionally

Returns a new result that, when this result completes exceptionally, completes with the value obtained from executing the supplied function with this result's exception as an argument. Otherwise, if this result completes normally, then the returned result also completes normally with the same value.

abstract fun exceptionally(fn: Function<Throwable!, out T>!): AsyncResult<T>!

executeBlocking

Returns a result that, after the given blocking function executes asynchronously on ForkJoinPool#commonPool() and returns a result, completes when the returned result completes, with the same value or exception.

open static fun <T : Any!> executeBlocking(fn: Supplier<T>!): AsyncResult<T>!

Returns a result that, after the given blocking function executes asynchronously on an Executor and returns a result, completes when the returned result completes, with the same value or exception.

open static fun <T : Any!> executeBlocking(executor: Executor!, fn: Supplier<T>!): AsyncResult<T>!

Returns a result that, after the given blocking function executes asynchronously on a vertx context and returns a result, completes when the returned result completes, with the same value or exception.

open static fun <T : Any!> executeBlocking(vertx: Vertx!, fn: Supplier<T>!): AsyncResult<T>!

Returns a result that, after the given blocking function executes asynchronously on a vertx executor and returns a result, completes when the returned result completes, with the same value or exception.

open static fun <T : Any!> executeBlocking(executor: WorkerExecutor!, fn: Supplier<T>!): AsyncResult<T>!

get

Waits if necessary for the computation to complete, and then retrieves its result.

abstract fun get(): T?

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result.

abstract fun get(timeout: Long, unit: TimeUnit!): T?

handle

Returns a new result that, when this result completes either normally or exceptionally, completes with the value obtained from executing the supplied function with this result's value and exception as arguments.

abstract fun <U : Any!> handle(fn: BiFunction<in T, Throwable!, out U>!): AsyncResult<U>!

incomplete

Return an incomplete result, that can be later completed or failed.

open static fun <T : Any!> incomplete(): CompletableAsyncResult<T>!

isCancelled

Returns true if this task was cancelled before it completed normally.

abstract fun isCancelled(): Boolean

isCompletedExceptionally

Returns true if completed exceptionally or cancelled.

abstract fun isCompletedExceptionally(): Boolean

isDone

Returns true if completed normally, completed exceptionally or cancelled.

abstract fun isDone(): Boolean

runOnContext

Returns a result that, after the given function executes on a vertx context and returns a result, completes when the returned result completes, with the same value or exception.

open static fun <T : Any!> runOnContext(vertx: Vertx!, fn: Supplier<out AsyncResult<T>!>!): AsyncResult<T>!

then

Returns a new result that, when this result completes normally, completes with the same value or exception as the result returned after executing the given function with this results value as an argument.

abstract fun <U : Any!> then(fn: Function<in T, out AsyncResult<U>!>!): AsyncResult<U>!

thenAccept

Returns a completion that, when this result completes normally, completes after executing the supplied consumer with this result's value as an argument.

abstract fun thenAccept(consumer: Consumer<in T>!): AsyncCompletion!

thenAcceptBoth

Returns a completion that, when this result and the other result both complete normally, completes after executing the supplied consumer with both this result's value and the value from the other result as arguments.

abstract fun <U : Any!> thenAcceptBoth(other: AsyncResult<out U>!, consumer: BiConsumer<in T, in U>!): AsyncCompletion!

thenApply

Returns a result that, when this result completes normally, completes with the value obtained from executing the supplied function with this result's value as an argument.

abstract fun <U : Any!> thenApply(fn: Function<in T, out U>!): AsyncResult<U>!

thenCombine

Returns a result that, when this result and the other result both complete normally, completes with the value obtained from executing the supplied function with both this result's value and the value from the other result as arguments.

abstract fun <U : Any!, V : Any!> thenCombine(other: AsyncResult<out U>!, fn: BiFunction<in T, in U, out V>!): AsyncResult<V>!

thenCompose

When this result completes normally, invokes the given function with the resulting value and obtains a new AsyncCompletion.

abstract fun thenCompose(fn: Function<in T, out AsyncCompletion!>!): AsyncCompletion!

thenRun

Returns a new completion that, when this result completes normally, completes after given action is executed.

abstract fun thenRun(runnable: Runnable!): AsyncCompletion!

thenSchedule

Returns a new result that, when this result completes normally, completes with the same value or exception as the completion returned after executing the given function on the vertx context with this results value as an argument.

abstract fun <U : Any!> thenSchedule(vertx: Vertx!, fn: Function<in T, out AsyncResult<U>!>!): AsyncResult<U>!

thenScheduleApply

Returns a result that, when this result completes normally, completes with the value obtained from executing the supplied function on the vertx context with this result's value as an argument.

abstract fun <U : Any!> thenScheduleApply(vertx: Vertx!, fn: Function<in T, out U>!): AsyncResult<U>!

thenScheduleBlockingApply

Returns a result that, when this result completes normally, completes with the value obtained from executing the supplied blocking function on the vertx context with this result's value as an argument.

abstract fun <U : Any!> thenScheduleBlockingApply(vertx: Vertx!, fn: Function<in T, out U>!): AsyncResult<U>!

Returns a result that, when this result completes normally, completes with the value obtained from executing the supplied blocking function on the vertx executor with this result's value as an argument.

abstract fun <U : Any!> thenScheduleBlockingApply(executor: WorkerExecutor!, fn: Function<in T, out U>!): AsyncResult<U>!

thenScheduleBlockingRun

Returns a new completion that, when this result completes normally, completes after the given blocking action is executed on the vertx context.

abstract fun thenScheduleBlockingRun(vertx: Vertx!, runnable: Runnable!): AsyncCompletion!

Returns a new completion that, when this result completes normally, completes after the given blocking action is executed on the vertx executor.

abstract fun thenScheduleBlockingRun(executor: WorkerExecutor!, runnable: Runnable!): AsyncCompletion!

thenScheduleRun

Returns a new completion that, when this result completes normally, completes after the given action is executed on the vertx context.

abstract fun thenScheduleRun(vertx: Vertx!, runnable: Runnable!): AsyncCompletion!

whenComplete

Returns a new result that completes with the same value or exception as this result, after executing the given action with this result's value or exception.

abstract fun whenComplete(action: BiConsumer<in T, in Throwable!>!): AsyncResult<T>!

Inheritors

CompletableAsyncResult

An AsyncResult that can be later completed successfully with a provided value, or completed with an exception.

interface CompletableAsyncResult<T : Any!> : AsyncResult<T>