kotlin-flow-extensions / hu.akarnokd.kotlin.flow / Resumable

Resumable

open class Resumable : AtomicReference<Continuation<Any>>

Primitive for suspending and resuming coroutines on demand

Constructors

<init>

Resumable()

Primitive for suspending and resuming coroutines on demand

Functions

await

suspend fun await(): Unit

Await the resumption of this Resumable, suspending the current coroutine if necessary. Only one thread can call this method.

resume

fun resume(): Unit

Resume this Resumable, resuming any currently suspended await callers. This method can be called by any number of threads.

Inheritors

BufferingResumableCollector

open class BufferingResumableCollector<T> : Resumable

A collector that can buffer a fixed number of items and drain it with much less need to coordinate the resumption per items.

ResumableCollector

open class ResumableCollector<T> : Resumable

A collector that hosts a signal (value/error/completion) and allows waiting for the signal and a consumer to be ready to receive them.