liveBook · Manning

Coroutine

As explained in 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.

A coroutine is a lightweight concurrency task whose switching is controlled by the program rather than the operating system. Several coroutines can act within one thread, sharing that thread’s execution resources. section 10.5

Coroutines trade isolation for lower overhead. They cannot protect one another from a blocked thread: if that thread waits for console output, none of its coroutines can progress. Threads, processes, and virtual machines provide progressively stronger isolation, but generally require more overhead. section 10.5

Figure 10.5 Trade-offs relating to different forms of task isolation in computing. In general terms, increasing the isolation level increases the overhead.

Compare coroutine-style task sharing with processes, threads, and virtual machines through the isolation-versus-overhead trade-off. section 10.5

How Rust in Action: Systems programming concepts and techniques covers it

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.
How it connects
Connects coroutines to threads, processes, virtual machines, task virtualization, shared memory, and isolation.

Also explained in

Compare how 8 books explain coroutine →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.