liveBook · Manning

Coroutine

A coroutine is a computation that can suspend and later resume execution while retaining its state, enabling cooperative transfer of control.

How 8 Manning books explain it

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.

Read how Kotlin in Action, 2E explains coroutine →

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.

Read how Grokking Concurrency explains coroutine →

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.

Read how Learn C++ by Example explains coroutine →

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.

Read how Idiomatic Rust explains coroutine →

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

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.