Coroutine
A coroutine is a computation that can suspend and later resume execution while retaining its state, enabling cooperative transfer of control.
Python Concurrency with asyncio
A coroutine function is a Python function whose invocation produces a coroutine that can suspend and resume during asynchronous execution.
- How it is used
- Uses coroutines to keep applications responsive while long-running I/O operations wait on a single-threaded event loop.
- How deep it goes
- Defines async def, await, coroutine objects, suspension, resumption, tasks, and event-loop scheduling, but defers custom awaitable implementation details.
- Examples
- Demonstrates coroutine arithmetic, concurrent delays, an asyncio echo server, generator-based coroutines, and a mixed synchronous-asynchronous task runner.
- What you can do after
- Build asynchronous applications with async def, await, asyncio.run, tasks, non-blocking sockets, and concurrency-aware API handling.
Read how Python Concurrency with asyncio explains coroutine →
Kotlin in Action, 2E
A coroutine is a lightweight suspendable computation that can pause its execution and resume it later without blocking its underlying thread.
- How it is used
- Enables non-blocking concurrent operations in UI, networked, and server applications.
- How deep it goes
- Explains suspension, builders, thread relationships, dispatchers, and failure propagation; defers deeper suspension mechanics and structured concurrency treatment.
- Examples
- Uses sequential login and user-data loading, concurrent image overlaying, and a failing sibling beside a heartbeat coroutine.
- What you can do after
- Apply it via kotlinx.coroutines builders and suspending functions to write non-blocking sequential-looking concurrent code.
Grokking Concurrency
A coroutine is a computation or function whose execution can be paused and later resumed, enabling cooperative asynchronous control flow.
- How it is used
- Coordinates asynchronous tasks by letting paused work give another task time on the same thread.
- How deep it goes
- Defines pause and resume, then works through generator scheduling and a Future-based socket event loop.
- Examples
- Uses a Fibonacci generator, a burger order, and an asynchronous pizza server.
- What you can do after
- Build it from scratch with Python generators, futures, and an event loop to coordinate a nonblocking socket server.
Learn C++ by Example
A coroutine is a function whose execution can be suspended and resumed while preserving its state.
- How it is used
- Uses suspension to separate a mind-reader game's stateful interaction from the code that displays each turn.
- How deep it goes
- Explains keywords, state preservation, coroutine frames, and custom Task mechanics, while stopping short of full asynchronous implementation.
- Examples
- Demonstrates a mind-reader game and an alphabet generator that yields letters through an experimental generator type.
- What you can do after
- Apply coroutine suspension and resumption through a custom Task, and experiment with generator-style output where supported.
Idiomatic Rust
A coroutine is a function-like computation that can suspend its execution, yield values, and later resume or complete.
- How it is used
- Uses coroutines to express pausable functions and demonstrate stream iteration as an alternative control-flow pattern.
- How deep it goes
- Explains yielding versus return, resumption through the Coroutine trait, compiler-generated state-machine internals, and a stream-reader example.
- Examples
- Demonstrates yielding π before a string return, then iterating over numbered lines read from Cargo.toml.
- What you can do after
- Build it from scratch by writing a nightly coroutine that yields values or adapts a line-reading stream into iteration.
Building LLM Applications with DSPy
A coroutine is a function-like unit of computation that can pause and resume execution, enabling cooperative concurrency.
- How it is used
- Uses coroutines to run concurrent requests when an application spends much of its time waiting for language-model responses.
- How deep it goes
- Defines async functions, tasks, event loops, and await points, without detailing event-loop internals.
- Examples
- Demonstrates two coroutines waiting for different durations, gathered together with results and elapsed time printed.
- What you can do after
- Apply asyncio to run waiting tasks concurrently using coroutines and await points.
Read how Building LLM Applications with DSPy explains coroutine →
Functional Programming in Scala, Second Edition
A coroutine is a computation that can suspend execution and later resume while cooperatively transferring control to another computation.
- How it is used
- Uses cooperative suspension to represent and interpret effectful control flow without depending on the call stack.
- How deep it goes
- Explains constructors, continuations, interpreter steps, and trampolining, then connects the pattern to Free monads.
- Examples
- Uses Return, Suspend, FlatMap, unsafeRun, and a repeating printLine IO program as concrete artifacts.
- What you can do after
- Build it from scratch by representing effects as IO data and interpreting suspensions with a tail-recursive runner.
Read how Functional Programming in Scala, Second Edition explains coroutine →
Rust in Action: Systems programming concepts and techniques
A coroutine is a task-switching concurrency mechanism in which the program, rather than the operating system, controls switching within a thread.
- How it is used
- Explains lightweight concurrency by comparing coroutine task sharing with threads, processes, and virtual machines.
- How deep it goes
- Defines coroutine behavior and its blocked-thread limitation, but stops short of implementation steps or scheduling internals.
- Examples
- Uses coroutines stalled by console output and a figure comparing isolation levels and overhead.
- What you can do after
- Evaluate concurrency models by relating coroutine sharing, isolation, failure containment, and runtime overhead.
Read how Rust in Action: Systems programming concepts and techniques explains coroutine →
Related concepts
- functionkind of · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- taskused by · A task is a defined unit of work, computation, or action directed toward a result or objective.
- suspendable computationkind of · A suspendable computation is a computation whose execution can be paused and later resumed while preserving its logical progress.
- generatorused by · A generator is a language construct or computation that produces values incrementally on demand, typically suspending and resuming while preserving its state.
- sleepincludes · A sleep operation suspends execution of a thread, goroutine, or coroutine for a specified duration, blocking or yielding according to its execution model.
- launchproduced by · launch is a Kotlin coroutines builder that starts a coroutine and returns a handle for a computation that produces no result value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.







