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:
“... there is nothing more irritating to a feminist than the average Womans Page of a newspaper, with its out-dated assumption that all women have a common trade interest in the household arts, and a common leisure interest in clothes and the doings of high society. Womens interests to-day are as wide as the world.”
—Crystal Eastman (18811928)
“If we dreamed the same thing every night, it would affect us much as the objects we see every day. And if a common workman were sure to dream every night for twelve hours that he was a king, I believe he would be almost as happy as a king who should dream every night for twelve hours on end that he was a common workman.”
—Blaise Pascal (16231662)