|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.javaflow.Continuation
Snapshot of a thread execution state.
A Continuation
object is an immutable object that captures everything in
the Java stack. This includes
(1) current instruction pointer,
(2) return addresses, and
(3) local variables.
Continuation objects are used to restore the captured execution states later.
Method Summary | |
static Continuation |
continueWith(Continuation resumed)
Resumes the execution of the specified continuation from where it's left off. |
static Continuation |
continueWith(Continuation resumed,
java.lang.Object context)
Resumes the execution of the specified continuation from where it's left off. |
static java.lang.Object |
getContext()
get the current context. |
static Continuation |
startSuspendedWith(java.lang.Runnable target)
Creates a new Continuation object from the specified Runnable
object. |
static Continuation |
startWith(java.lang.Runnable target)
Starts executing the specified Runnable object in an environment
that allows suspend() . |
static Continuation |
startWith(java.lang.Runnable target,
java.lang.Object context)
Starts executing the specified Runnable object in an environment
that allows suspend() . |
static void |
suspend()
Stops the running continuation. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
public static java.lang.Object getContext()
This method returns the same context object given to startWith(Runnable, Object)
or continueWith(Continuation, Object)
.
A different context can be used for each run of a continuation, so this mechanism can be used to associate some state with each execution.
startWith(Runnable, Object)
or continueWith(Continuation, Object)
.public static Continuation startSuspendedWith(java.lang.Runnable target)
Continuation
object from the specified Runnable
object.
Unlike the startWith(Runnable)
method, this method doesn't actually
execute the Runnable object. It will be executed when
it's continued
.
public static Continuation startWith(java.lang.Runnable target)
Runnable
object in an environment
that allows suspend()
.
This is a short hand for startWith(target,null).
startWith(Runnable, Object).
public static Continuation startWith(java.lang.Runnable target, java.lang.Object context)
Runnable
object in an environment
that allows suspend()
.
This method blocks until the continuation suspends or completes.
target
- The object whose run method will be executed.context
- This value can be obtained from getContext()
until this method returns.
Can be null.
suspended
, in which case
a new non-null continuation is returned.getContext()
public static Continuation continueWith(Continuation resumed)
This is a short hand for continueWith(resumed,null).
continueWith(Continuation, Object)
public static Continuation continueWith(Continuation resumed, java.lang.Object context)
resumed
- The resumed continuation to be executed. Must not be null.context
- This value can be obtained from getContext()
until this method returns.
Can be null.
suspended
, in which case
a new non-null continuation is returned.getContext()
public static void suspend()
This method can be only called inside continueWith(org.apache.commons.javaflow.Continuation)
or startWith(java.lang.Runnable)
methods.
When called, the thread returns from the above methods with a new Continuation
object that captures the thread state.
java.lang.IllegalStateException
- if this method is called outside the continueWith(org.apache.commons.javaflow.Continuation)
or startWith(java.lang.Runnable)
methods.public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |