All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class javaCoroutine.Coroutine

java.lang.Object
   |
   +----javaCoroutine.Coroutine

public abstract class Coroutine
extends java.lang.Object
This class may be used for coroutine sequencing in Java.

Coroutines are created as instances of Coroutine-derived classes that override the abstract method body. The body method is used to specify their actions.

A coroutine may temporarily suspend its execution and another coroutine may take over. A suspended coroutine may later be resumed at the point where it was suspended.

Resumption can be performed by one of two operations, resume(c) and call(c), where c is a Coroutine-object.

Both operations resumes c and supends the currently executing coroutine.

The call operation furthermore establishes the current coroutine as c's caller. Coroutine c is said to be attached to its caller.

A coroutine can relinquish control to its caller by means of the operation detach(). This causes the caller to resume its execution from the point where it last left off.


Constructor Index

 o Coroutine()

Method Index

 o call(Coroutine)
Calls the specified coroutine and suspends the currently executing coroutine.
 o currentCoroutine()
Returns the currently operating coroutine.
 o detach()
Detaches the specified coroutine.
 o mainCoroutine()
Returns the main coroutine.
 o resume(Coroutine)
Resumes the specified coroutine and suspends the currently executing coroutine.

Constructors

 o Coroutine
 public Coroutine()

Methods

 o resume
 public static final void resume(javaCoroutine.Coroutine next)
Resumes the specified coroutine and suspends the currently executing coroutine.

The coroutine is resumed from the point where if last left off.

Parameters:
next - The coroutine to be resumed.
Throws: RuntimeException
if next is terminated, attached or null.
 o call
 public static final void call(javaCoroutine.Coroutine next)
Calls the specified coroutine and suspends the currently executing coroutine.

The coroutine is attached to the current coroutine and resumed from the point where if last left off.

Parameters:
next - The coroutine to be called.
Throws: RuntimeException
if next is terminated, attached or null.
 o detach
 public static final void detach()
Detaches the specified coroutine.

The coroutine is suspended and its caller is resumed.

If the coroutine has no caller, the "main coroutine" is resumed. The main coroutine designates the first coroutine resumed (or called) in a system of coroutines.

 o currentCoroutine
 public static final javaCoroutine.Coroutine currentCoroutine()
Returns the currently operating coroutine.

 o mainCoroutine
 public static final javaCoroutine.Coroutine mainCoroutine()
Returns the main coroutine.


All Packages  Class Hierarchy  This Package  Previous  Next  Index