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:
“I dont have any doubts that there will be a place for progressive white people in this country in the future. I think the paranoia common among white people is very unfounded. I have always organized my life so that I could focus on political work. Thats all I want to do, and thats all that makes me happy.”
—Hettie V., South African white anti-apartheid activist and feminist. As quoted in Lives of Courage, ch. 21, by Diana E. H. Russell (1989)
“Many women cut back what had to be done at home by redefining what the house, the marriage and, sometimes, what the child needs. One woman described a fairly common pattern: I do my half. I do half of his half, and the rest doesnt get done.”
—Arlie Hochschild (20th century)