concurrent / org.apache.tuweni.concurrent / CompletableAsyncCompletion

CompletableAsyncCompletion

interface CompletableAsyncCompletion : AsyncCompletion (source)

An AsyncCompletion that can later be completed successfully or with a provided exception.

Inherited Properties

COMPLETED

static val COMPLETED: AsyncCompletion

Functions

complete

abstract fun complete(): Boolean

Complete this completion.

completeExceptionally

abstract fun completeExceptionally(ex: Throwable): Boolean

Complete this completion with the given exception.

Inherited Functions

accept

abstract fun accept(consumer: Consumer<in Throwable>): AsyncCompletion

Returns a new completion that completes successfully, after executing the given function with this completion's exception (if any).

The exception supplied to the function will be null if this completion completes successfully.

cancel

abstract fun cancel(): Boolean

Attempt to cancel execution of this task.

This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started when cancel is called, this task should never run.

After this method returns, subsequent calls to #isDone() will always return true. Subsequent calls to #isCancelled() will always return true if this method returned true.

exceptionally

abstract fun exceptionally(consumer: Consumer<in Throwable>): AsyncCompletion

Returns a new completion that, when this result completes exceptionally, completes after executing the supplied function. Otherwise, if this result completes normally, then the returned result also completes normally with the same value.

handle

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

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 exception (if any) as an argument.

The exception supplied to the function will be null if this completion completes successfully.

isCancelled

abstract fun isCancelled(): Boolean

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

isCompletedExceptionally

abstract fun isCompletedExceptionally(): Boolean

Returns true if completed exceptionally or cancelled.

isDone

abstract fun isDone(): Boolean

Returns true if completed normally, completed exceptionally or cancelled.

join

abstract fun join(): Unit

Waits if necessary for the computation to complete.

abstract fun join(timeout: Long, unit: TimeUnit): Unit

Waits if necessary for at most the given time for the computation to complete.

then

abstract fun <U : Any> then(fn: Supplier<out AsyncResult<U>>): AsyncResult<U>

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

thenApply

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

Returns a result that, when this completion and the other result both complete normally, completes with the value obtained from executing the supplied function with the value from the other result as an argument.

thenCombine

abstract fun thenCombine(other: AsyncCompletion): AsyncCompletion

Returns a completion that completes when both this completion and the other complete normally.

thenCompose

abstract fun thenCompose(fn: Supplier<out AsyncCompletion>): AsyncCompletion

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

thenConsume

abstract fun <U : Any> thenConsume(other: AsyncResult<out U>, consumer: Consumer<in U>): AsyncCompletion

Returns a completion that, when this completion and the supplied result both complete normally, completes after executing the supplied function with the value from the supplied result as an argument.

thenRun

abstract fun thenRun(runnable: Runnable): AsyncCompletion

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

thenSchedule

abstract fun <U : Any> thenSchedule(vertx: Vertx, fn: Supplier<out AsyncResult<U>>): AsyncResult<U>

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

thenScheduleBlockingRun

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

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

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

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

thenScheduleRun

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

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

thenSupply

abstract fun <U : Any> thenSupply(supplier: Supplier<out U>): AsyncResult<U>

Returns a completion that, when this result completes normally, completes with the value obtained after executing the supplied function.

abstract fun <U : Any> thenSupply(vertx: Vertx, supplier: Supplier<out U>): AsyncResult<U>

Returns a completion that, when this result completes normally, completes with the value obtained after executing the supplied function on the vertx context.

whenComplete

abstract fun whenComplete(consumer: Consumer<in Throwable>): AsyncCompletion

Returns a new completion that completes in the same manner as this completion, after executing the given function with this completion's exception (if any).

The exception supplied to the function will be null if this completion completes successfully.