Designing Coroutines
Simula’s concept of coroutines was genuinely revolutionary in the era of single-CPU computers (see the list) with limited or no multitasking.
A coroutine is a dynamic instance of a block of executable code, such as the body of a class, with its local variables and the program counter. A coroutine can be in one of four states: attached, detached, resumed, or terminated, as illustrated by the following UML diagram. (Not familiar with UML? No problem! You’ll find numerous UML resources in both printed—UML Distilled: A Brief Guide to the Standard Object Modeling Language [Fow03]—and electronic form.)[22]

Your program may comprise ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access