...
Symmetric coroutines are implemented via the Coroutine class. This is used by either subclassing Coroutine and overriding the run method or passing a target Runnable to the Coroutine constructor.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class Coroutine { public Coroutine(); public Coroutine(Runnable target); public Coroutine(long stacksize); public Coroutine(Runnable target, long stacksize); public static void yield(); public static void yieldTo(Coroutine target); protected void run(); } |
...
- they are prepared to take an input value and return an output value
- these input and output values are of generic type
- the caller/callee relationship of asymmetric coroutines leads to a differentiation between "calling" a coroutine and "returning" from it
- it implements Iterable so it can be used in for-each loops
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public abstract class AsymCoroutine<InT, OutT> implements Iterable<OutT> { public AsymCoroutine(); public AsymCoroutine(long stacksize); public InT ret(OutT value); public InT ret(); public OutT call(InT input); public OutT call(); protected abstract OutT run(InT value); @Override public Iterator<OutT> iterator(); } |
...
Overview
Content Tools
ThemeBuilder