-
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>
-
-
Constructor Summary
Constructors Constructor Description TaskCompletionSource()
-
Method Summary
Modifier and Type Method Description final Task<TResult>
getTask()
final Boolean
trySetCancelled()
Sets the cancelled flag on the Task if the Task hasn't already been completed. final Boolean
trySetResult(TResult result)
Sets the result on the Task if the Task hasn't already been completed. final Boolean
trySetError(Exception error)
Sets the error on the Task if the Task hasn't already been completed. final Unit
setCancelled()
Sets the cancelled flag on the task, throwing if the Task has already been completed. final Unit
setResult(TResult result)
Sets the result of the Task, throwing if the Task has already been completed. final Unit
setError(Exception error)
Sets the error of the Task, throwing if the Task has already been completed. -
-
Method Detail
-
trySetCancelled
final Boolean trySetCancelled()
Sets the cancelled flag on the Task if the Task hasn't already been completed.
-
trySetResult
final Boolean trySetResult(TResult result)
Sets the result on the Task if the Task hasn't already been completed.
-
trySetError
final Boolean trySetError(Exception error)
Sets the error on the Task if the Task hasn't already been completed.
-
setCancelled
final Unit setCancelled()
Sets the cancelled flag on the task, throwing if the Task has already been completed.
-
setResult
final Unit setResult(TResult result)
Sets the result of the Task, throwing if the Task has already been completed.
-
-
-
-