|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectde.matthiasmann.continuations.Coroutine
public class Coroutine
A Coroutine is used to run a CoroutineProto.
It also provides a function to suspend a running Coroutine.
A Coroutine can be serialized if it's not running and all involved
classes and data types are also Serializable.
| Nested Class Summary | |
|---|---|
static class |
Coroutine.State
|
| Constructor Summary | |
|---|---|
Coroutine(CoroutineProto proto)
Creates a new Coroutine from the given CoroutineProto. |
|
| Method Summary | |
|---|---|
static Coroutine |
getActiveCoroutine()
Returns the active Coroutine on this thread or NULL if no coroutine is running. |
CoroutineProto |
getProto()
Returns the CoroutineProto that is used for this Coroutine |
Coroutine.State |
getState()
Returns the current state of this Coroutine. |
void |
run()
Runs the Coroutine until it is finished or suspended. |
static void |
yield()
Suspend the currently running Coroutine on the calling thread. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Coroutine(CoroutineProto proto)
proto - The CoroutineProto for the Coroutine.| Method Detail |
|---|
public static void yield()
throws SuspendExecution,
java.lang.IllegalStateException
SuspendExecution - This exception is used for control transfer - don't catch it !
java.lang.IllegalStateException - If not called from a Coroutinepublic static Coroutine getActiveCoroutine()
public CoroutineProto getProto()
public Coroutine.State getState()
Returns the current state of this Coroutine. May be called by the Coroutine itself but should not be called by another thread.
The Coroutine starts in the state NEW then changes to RUNNING. From RUNNING it may change to FINISHED or SUSPENDED. SUSPENDED can only change to RUNNING by calling run() again.
run()
public void run()
throws java.lang.IllegalStateException
run in interface java.lang.Runnablejava.lang.IllegalStateException - if the Coroutine is currently running or already finished.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||