DeferredFuture

A future whose value of type T can be set later. Internally, it uses a mutex lock which is locked as soon as the instance is created. Once the value is set, the lock is released. Therefore, any callers of await are blocked until value is set.

class DeferredFuture<T> : Future<T>

Parameters

T

the type of value this future instance holds.

Constructors

DeferredFuture
Link copied to clipboard
ios

the type of value this future instance holds.

fun DeferredFuture()

Functions

await
Link copied to clipboard
ios

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
ios
open operator override fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
ios
open override fun hashCode(): Int
setValue
Link copied to clipboard
ios

Sets the value to the newValue of the future and releases the lock

fun setValue(newValue: T)
toString
Link copied to clipboard
ios
open override fun toString(): String

Properties

isCompleted
Link copied to clipboard
ios

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

open override var isCompleted: Boolean