Task

Represents the result of an asynchronous operation.

Types

Link copied to clipboard
Interface for handlers invoked when a failed Task is about to be finalized, but the exception has not been consumed.

Properties

Link copied to clipboard
open val error: Exception
Link copied to clipboard
An java.util.concurrent.Executor that executes tasks in the current thread unless the stack runs too deep, at which point it will delegate to BACKGROUND_EXECUTOR in order to trim the stack.
Link copied to clipboard
open val result: TResult
Link copied to clipboard
An java.util.concurrent.Executor that executes tasks on the UI thread.

Functions

Link copied to clipboard
open fun <TResult> call(callable: Callable<TResult>, executor: Executor): Task<TResult>
Invokes the callable using the given executor, returning a Task to represent the operation.
Link copied to clipboard
open fun <TResult> cancelled(): Task<TResult>
Creates a cancelled task.
Link copied to clipboard
Adds a synchronous continuation to this task, returning a new task that completes after the continuation has finished running.
open fun <TContinuationResult> continueWith(continuation: Continuation<TResult, TContinuationResult>, executor: Executor): Task<TContinuationResult>
Adds a continuation that will be scheduled using the executor, returning a new task that completes after the continuation has finished running.
Link copied to clipboard
Adds an asynchronous continuation to this task, returning a new task that completes after the task returned by the continuation has completed.
Adds an Task-based continuation to this task that will be scheduled using the executor, returning a new task that completes after the task returned by the continuation has completed.
Link copied to clipboard
open fun <TResult> create(): TaskCompletionSource
Link copied to clipboard
open fun <TResult> forError(error: Exception): Task<TResult>
Creates a faulted task with the given error.
Link copied to clipboard
open fun <TResult> forResult(@Nullable value: TResult): Task<TResult>
Creates a completed task with the given value.
Link copied to clipboard
abstract fun getError(): Exception
Link copied to clipboard
abstract fun getResult(): TResult
Link copied to clipboard
open fun isCancelled(): Boolean
Link copied to clipboard
open fun isCompleted(): Boolean
Link copied to clipboard
open fun isFaulted(): Boolean
Link copied to clipboard
open fun makeVoid(): Task<Void>
Turns a Taskinto a Task
Link copied to clipboard
Runs a continuation when a task completes successfully, forwarding along s or cancellation.
open fun <TContinuationResult> onSuccess(continuation: Continuation<TResult, TContinuationResult>, executor: Executor): Task<TContinuationResult>
Runs a continuation when a task completes successfully, forwarding along or cancellation.
Link copied to clipboard
open fun <TContinuationResult> onSuccessTask(continuation: Continuation<TResult, Task<TContinuationResult>>, executor: Executor): Task<TContinuationResult>
Runs a continuation when a task completes successfully, forwarding along s or cancellation.
Link copied to clipboard
Blocks until the task is complete.
open fun waitForCompletion(duration: Long, timeUnit: TimeUnit): Boolean
Blocks until the task is complete or times out.