Coroutines

Added in 1.0.0-alpha01

public final class Coroutines


Summary

Public methods

static final @NonNull ListenableFuture<@NonNull T>
<T extends Object> toFuture(
    @NonNull Session session,
    @ExtensionFunctionType @NonNull SuspendFunction1<@NonNull CoroutineScope, @NonNull T> coroutine
)

Converts a coroutine created within the session to a ListenableFuture.

Public methods

public static final @NonNull ListenableFuture<@NonNull T> <T extends Object> toFuture(
    @NonNull Session session,
    @ExtensionFunctionType @NonNull SuspendFunction1<@NonNull CoroutineScope, @NonNull T> coroutine
)

Converts a coroutine created within the session to a ListenableFuture.

The returned ListenableFuture will be automatically cancelled when the session is destroyed.

Parameters
@NonNull Session session

the Session that originated the coroutine.

@ExtensionFunctionType @NonNull SuspendFunction1<@NonNull CoroutineScope, @NonNull T> coroutine

the coroutine to convert to a ListenableFuture.