Android SDK Version


public class TaskCompletionSource<TResult extends Object>
Allows safe orchestration of a task's completion, preventing the consumer from prematurely completing the task. Essentially, it represents the producer side of a Task<TResult>, providing access to the consumer side through the getTask() method while isolating the Task's completion mechanisms from the consumer. </TResult>
Field Summary
Modifier and TypeFieldDescription
private final Task<TResult>task
Constructor Summary
ConstructorDescription
TaskCompletionSource()
Method Summary
Modifier and TypeMethodDescription
final Task<TResult>getTask()
final BooleantrySetCancelled() Sets the cancelled flag on the Task if the Task hasn't already been completed.
final BooleantrySetResult(TResult result) Sets the result on the Task if the Task hasn't already been completed.
final BooleantrySetError(Exception error) Sets the error on the Task if the Task hasn't already been completed.
final UnitsetCancelled() Sets the cancelled flag on the task, throwing if the Task has already been completed.
final UnitsetResult(TResult result) Sets the result of the Task, throwing if the Task has already been completed.
final UnitsetError(Exception error) Sets the error of the Task, throwing if the Task has already been completed.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail

TaskCompletionSource

TaskCompletionSource()
Method Detail

getTask

 final Task<TResult> getTask()

trySetCancelled

 final BooleantrySetCancelled()
Sets the cancelled flag on the Task if the Task hasn't already been completed.

trySetResult

 final BooleantrySetResult(TResult result)
Sets the result on the Task if the Task hasn't already been completed.

trySetError

 final BooleantrySetError(Exception error)
Sets the error on the Task if the Task hasn't already been completed.

setCancelled

 final UnitsetCancelled()
Sets the cancelled flag on the task, throwing if the Task has already been completed.

setResult

 final UnitsetResult(TResult result)
Sets the result of the Task, throwing if the Task has already been completed.

setError

 final UnitsetError(Exception error)
Sets the error of the Task, throwing if the Task has already been completed.