The main coroutines guide has moved to the
docs folder
and split up into smaller documents.
Table of contents
Coroutine Basics
Your first coroutine
Bridging blocking and non-blocking worlds
Waiting for a job
Structured concurrency
Scope builder
Extract function refactoring
Coroutines ARE light-weight
Global coroutines are like daemon threads
Cancellation and Timeouts
Cancelling coroutine execution
Cancellation is cooperative
Making computation code cancellable
Closing resources with
finally
Run non-cancellable block
Timeout
Composing Suspending Functions
Sequential by default
Concurrent using async
Lazily started async
Async-style functions
Structured concurrency with async
Coroutine Context and Dispatchers
Dispatchers and threads
Unconfined vs confined dispatcher
Debugging coroutines and threads
Jumping between threads
Job in the context
Children of a coroutine
Parental responsibilities
Naming coroutines for debugging
Combining context elements
Coroutine scope
Thread-local data
Asynchronous Flow
Representing multiple values
Sequences
Suspending functions
Flows
Flows are cold
Flow cancellation
Flow builders
Intermediate flow operators
Transform operator
Size-limiting operators
Terminal flow operators
Flows are sequential
Flow context
Wrong emission withContext
flowOn operator
Buffering
Conflation
Processing the latest value
Composing multiple flows
Zip
Combine
Flattening flows
flatMapConcat
flatMapMerge
flatMapLatest
Flow exceptions
Collector try and catch
Everything is caught
Exception transparency
Transparent catch
Catching declaratively
Flow completion
Imperative finally block
Declarative handling
Upstream exceptions only
Imperative versus declarative
Launching flow
Flow and Reactive Streams
Channels
Channel basics
Closing and iteration over channels
Building channel producers
Pipelines
Prime numbers with pipeline
Fan-out
Fan-in
Buffered channels
Channels are fair
Ticker channels
Exception Handling
Exception propagation
CoroutineExceptionHandler
Cancellation and exceptions
Exceptions aggregation
Supervision
Supervision job
Supervision scope
Exceptions in supervised coroutines
Shared mutable state and concurrency
The problem
Volatiles are of no help
Thread-safe data structures
Thread confinement fine-grained
Thread confinement coarse-grained
Mutual exclusion
Actors
Select Expression (experimental)
Selecting from channels
Selecting on close
Selecting to send
Selecting deferred values
Switch over a channel of deferred values