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
Cancellation via explicit job
Thread-local data
Exception handling
Exception propagation
CoroutineExceptionHandler
Cancellation and exceptions
Exceptions aggregation
Supervision
Supervision job
Supervision scope
Exceptions in supervised coroutines
Channels (experimental)
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
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