- Loading...
 
...
Many dynamic languages that have JVM-based runtime environments already support coroutine-like features.
 Thus, coroutine support would also help these runtime environments provide an efficient implementation of these features.
...
Coroutines can be implemented very efficiently.
 They can be applied to all platforms that at the moment support threading, and could be used as a lightweight alternative to threading on platforms that don't.
...
The current java.lang.Thread system is designed for preemptive, operating-system level context switching.
 This inherently is orders of magnitude slower that user-level context switching.
Coroutines as a programming concept have been around since the early days of computer science, the term "coroutine" itself was coined in 1963 by Melvin Conway (http://dx.doi.org/10.1145%2F366663.366704).
 They are available in numerous programming languages and runtime environments.
From a language design perspective, coroutines are a generalization of subroutines.
 When they are invoked, they start execution at their first statement and they can subsequently transfer control to some other coroutine (via an operation often called yield).
 The state of the local variables and the expression stack at the transfer point is preserved.
 When control is transferred back, the coroutine resumes the preserved state and continues to run from the point where it relinquished control.
Coroutines can also be seen as a limited form of continuations, called one-shot continuations.
From a VM perspective, coroutines can be seen as a limited version of threads that happen to transfer control only at some user-specified points in the program.
 For the sake of this document, this is the most useful definition, because it can be used to infer sensible memory model and runtime semantics for coroutines.
Coroutines have been seen as an inferior alternative to full-blown threads, because of the manual context switching.
 However, there are situations in which manual context switching makes sense or is even desired.
...
The thesis should provide a starting point for discussions about the features that a coroutine implementation should provide, and the prototype implementation can be seen as a proof-of-concept that can be used to explore the API design and performance characteristics.
...