ValueFuture

A naive future implementation to wrap a given result. It executes on the calling thread synchronously.

Examples

val future: Future<String> = ValueFuture("hello")
val result: String = future.await()

class ValueFuture<T>(result: T) : Future<T>

Constructors

ValueFuture
Link copied to clipboard
common
fun <T> ValueFuture(result: T)

Functions

await
Link copied to clipboard
common

Consume the future value in code as input. This method may or may not block the calling thread depending upon the implementation.

Examples

val future: Future<T> = // some api which returns a Future<T>
val value: R = future.await() // blocks until future completes

open override fun await(): T
equals
Link copied to clipboard
common
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
common
open override fun hashCode(): Int
toString
Link copied to clipboard
common
open override fun toString(): String

Properties

isCompleted
Link copied to clipboard
common

Returns true if the future has completed and is ready to await.

open override var isCompleted: Boolean