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:
“The common consolation which some good christian or other, is hourly administering to himself,that he thanks God his mind does not misgive him; and that, consequently, he has a good conscience, because he has a quiet one,is fallacious.”
—Laurence Sterne (17131768)
“If you meet a sectary, or a hostile partisan, never recognize the dividing lines; but meet on what common ground remains,if only that the sun shines, and the rain rains for both; the area will widen very fast, and ere you know it the boundary mountains, on which the eye had fastened, have melted into air.”
—Ralph Waldo Emerson (18031882)
Related Subjects
Related Phrases
Related Words