CallbackToFutureAdapter.Completer


class CallbackToFutureAdapter.Completer<T>


Used to complete the future returned by getFuture

Summary

Public functions

Unit
addCancellationListener(runnable: Runnable, executor: Executor)

Use to propagate cancellation from the future to whatever operation is using this Completer.

Boolean
set(value: T!)

Sets the result of the Future unless the Future has already been cancelled or set.

Boolean

Cancels Future unless the Future has already been cancelled or set.

Boolean

Sets the failed result of the Future unless the Future has already been cancelled or set.

Protected functions

Unit

Public functions

addCancellationListener

Added in 1.0.0
fun addCancellationListener(runnable: Runnable, executor: Executor): Unit

Use to propagate cancellation from the future to whatever operation is using this Completer.

Will be called when the returned Future is cancelled by cancel or this Completer object is garbage collected before the future completes. Not triggered by setCancelled.

set

Added in 1.0.0
fun set(value: T!): Boolean

Sets the result of the Future unless the Future has already been cancelled or set. When a call to this method returns, the Future is guaranteed to be done.

Parameters
value: T!

the value to be used as the result

Returns
Boolean

true if this attempt completed the Future, false if it was already complete

setCancelled

Added in 1.0.0
fun setCancelled(): Boolean

Cancels Future unless the Future has already been cancelled or set. When a call to this method returns, the Future is guaranteed to be done.

Returns
Boolean

true if this attempt completed the Future, false if it was already complete

setException

Added in 1.0.0
fun setException(t: Throwable): Boolean

Sets the failed result of the Future unless the Future has already been cancelled or set. When a call to this method returns, the Future is guaranteed to be done.

Parameters
t: Throwable

the exception to be used as the failed result

Returns
Boolean

true if this attempt completed the Future, false if it was already complete

Protected functions

finalize

Added in 1.0.0
protected fun finalize(): Unit