Coroutine - Common Uses

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 am convinced that our American society will become more and more vulgarized and that it will be fragmentized into contending economic, racial and religious pressure groups lacking in unity and common will, unless we can arrest the disintegration of the family and of community solidarity.
    Agnes E. Meyer (1887–1970)

    It is common knowledge to every schoolboy and even every Bachelor of Arts,
    That all sin is divided into two parts.
    One kind of sin is called a sin of commission, and that is very
    important,
    Ogden Nash (1902–1971)