Package kotlin.coroutines.experimental

Deprecated support for experimental coroutines, provided for compatibility. It's recommended to migrate to kotlin.coroutines API.

Types

Common
JVM
JS
Native
1.1

AbstractCoroutineContextElement

Base class for CoroutineContext.Element implementations.

abstract class AbstractCoroutineContextElement : Element
Common
JVM
JS
Native
1.1

Continuation

Interface representing a continuation after a suspension point that returns value of type T.

interface Continuation<in T>
Common
JVM
JS
Native
1.1

ContinuationInterceptor

Marks coroutine context element that intercepts coroutine continuations. The coroutines framework uses ContinuationInterceptor.Key to retrieve the interceptor and intercepts all coroutine continuations with interceptContinuation invocations.

interface ContinuationInterceptor : Element
Common
JVM
JS
Native
1.1

CoroutineContext

Persistent context for the coroutine. It is an indexed set of Element instances. An indexed set is a mix between a set and a map. Every element in this set has a unique Key. Keys are compared by reference.

interface CoroutineContext
Common
JVM
JS
Native
1.1

EmptyCoroutineContext

An empty coroutine context.

object EmptyCoroutineContext : CoroutineContext
Common
JVM
JS
Native
1.1

SequenceBuilder

Builder for a Sequence or an Iterator, provides yield and yieldAll suspension functions.

abstract class SequenceBuilder<in T>

Annotations

Common
JVM
JS
Native
1.1

RestrictsSuspension

Classes and interfaces marked with this annotation are restricted when used as receivers for extension suspend functions. These suspend extensions can only invoke other member or extension suspend functions on this particular receiver only and are restricted from calling arbitrary suspension functions.

annotation class RestrictsSuspension

Properties

Common
JVM
JS
Native
1.2

coroutineContext

Continuation context of current coroutine.

suspend val coroutineContext: CoroutineContext

Functions

Common
JVM
JS
Native
1.1

buildIterator

Builds an Iterator lazily yielding values one by one.

fun <T> buildIterator(
    builderAction: suspend SequenceBuilder<T>.() -> Unit
): Iterator<T>
Common
JVM
JS
Native
1.1

buildSequence

Builds a Sequence lazily yielding values one by one.

fun <T> buildSequence(
    builderAction: suspend SequenceBuilder<T>.() -> Unit
): Sequence<T>
Common
JVM
JS
Native
1.1

createCoroutine

Creates a coroutine with receiver type R and result type T. This function creates a new, fresh instance of suspendable computation every time it is invoked.

fun <R, T> (suspend R.() -> T).createCoroutine(
    receiver: R,
    completion: Continuation<T>
): Continuation<Unit>

Creates a coroutine without receiver and with result type T. This function creates a new, fresh instance of suspendable computation every time it is invoked.

fun <T> (suspend () -> T).createCoroutine(
    completion: Continuation<T>
): Continuation<Unit>
Common
JVM
JS
Native
1.1

startCoroutine

Starts coroutine with receiver type R and result type T. This function creates and start a new, fresh instance of suspendable computation every time it is invoked. The completion continuation is invoked when coroutine completes with result or exception.

fun <R, T> (suspend R.() -> T).startCoroutine(
    receiver: R,
    completion: Continuation<T>)

Starts coroutine without receiver and with result type T. This function creates and start a new, fresh instance of suspendable computation every time it is invoked. The completion continuation is invoked when coroutine completes with result or exception.

fun <T> (suspend () -> T).startCoroutine(
    completion: Continuation<T>)
Common
JVM
JS
Native
1.1

suspendCoroutine

Obtains the current continuation instance inside suspend functions and suspends currently running coroutine.

suspend fun <T> suspendCoroutine(
    block: (Continuation<T>) -> Unit
): T