Weitere Beispiele werden automatisch zu den Stichwörtern zugeordnet - wir garantieren ihre Korrektheit nicht.
Any subroutine can be translated to a coroutine which does not call yield.
A third function, which can usually be written in machine-specific C, is needed to create the context for a new coroutine.
The call mechanism invokes a procedure as a coroutine.
The queue is then completely filled or emptied before yielding control to the other coroutine using the yield command.
As such, when a coroutine is all that is needed, using a thread can be overkill.
This example shows the use of the 'foreach' loop to iterate over a coroutine.
The term coroutine was originated by Melvin Conway in a 1963 paper.
Communicating sequential processes where each sub-process is a coroutine.
Basic tasks never block; they "run to completion" (coroutine).
The standard C library includes functions named setjmp and longjmp which can be used to implement a form of coroutine.
The main shortcoming of this approach is that the coroutine's stack is a fixed size and cannot be grown during execution.
Softpanorama coroutine page Contains extensive assembler coroutines links.
Coroutine - created by Oliver Kowalke, is the official released portable coroutine library of boost since version 1.53.
Explicit cooperation of each coroutine is required, (i.e., each coroutine must check for data availability before blocking reads).
One subroutine may have multiple distinct entry points or exit flows (see coroutine); if so, these are shown as labeled 'wells' in the rectangle, and control arrows connect to these 'wells'.
Indeed, setjmp/longjmp, because it only countenances a single stack, cannot be used to implement natural coroutines, as variables located on the stack will be overwritten as another coroutine uses the same stack space.
Coroutine - Giovanni P. Deretta created while his "Google Summer of Code 2006" project this portable coroutine library which relies heavily on boost and C++ templates.
The difference between calling another coroutine by means of "yielding" to it and simply calling another routine (which then, also, would return to the original point), is that the latter is entered in the same continuous manner as the former.
A similar approach to multitasking is to instead use coroutines which call each other, where rather than terminating by calling another routine, one coroutine yields to another but does not terminate, and then resumes execution when it is yielded back to.
In situations where a coroutine would be the natural implementation of a mechanism, but is not available, the typical response is to create a subroutine that uses an ad-hoc assemblage of boolean flags and other state variables to maintain an internal state between calls.
Coroutines are similar except they can also exit by calling other coroutines, which may later return to the point of calling in the original coroutine; from the coroutine's point of view, it is not exiting at all but simply calling another coroutine.