Common Uses
Coroutines are useful to implement the following:
- State machines within a single subroutine, where the state is determined by the current entry/exit point of the procedure; this can result in more readable code.
- Actor model of concurrency, for instance in video games. Each actor has its own procedures (this again logically separates the code), but they voluntarily give up control to central scheduler, which executes them sequentially (this is a form of cooperative multitasking).
- Generators, and these are useful for input/output and for generic traversal of data structures.
Read more about this topic: Coroutine
Famous quotes containing the word common:
“We are the creatures of imagination, passion, and self- will, more than of reason or even of self-interest.... Even in the common transactions and daily intercourse of life, we are governed by whim, caprice, prejudice, or accident. The falling of a teacup puts us out of temper for the day; and a quarrel that commenced about the pattern of a gown may end only with our lives.”
—William Hazlitt (17781830)
“In common with other rural regions much of the Iowa farm lore concerns the coming of company. When the rooster crows in the doorway, or the cat licks his fur, company is on the way.”
—For the State of Iowa, U.S. public relief program (1935-1943)