Package com.offbynull.coroutines.user
Class CoroutineRunner
java.lang.Object
com.offbynull.coroutines.user.CoroutineRunner
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Continuation
private Coroutine
private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionCoroutineRunner
(Coroutine coroutine) Constructs aCoroutineRunner
object.CoroutineRunner
(Coroutine coroutine, Continuation continuation) -
Method Summary
Modifier and TypeMethodDescriptionboolean
execute()
Starts/resumes execution of this coroutine.Get the context.(package private) Continuation
Get the coroutine assigned to this runner.void
setContext
(Object context) Set the context.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
coroutine
-
continuation
-
-
Constructor Details
-
CoroutineRunner
Constructs aCoroutineRunner
object.- Parameters:
coroutine
- coroutine to run- Throws:
NullPointerException
- if any argument isnull
-
CoroutineRunner
CoroutineRunner(Coroutine coroutine, Continuation continuation)
-
-
Method Details
-
execute
public boolean execute()Starts/resumes execution of this coroutine. If the coroutine being executed reaches a suspension point (meaning that the method callsContinuation.suspend()
), this method will returntrue
. If the coroutine has finished executing, this method will returnfalse
.Calling this method again after the coroutine has finished executing will restart the coroutine.
- Returns:
false
if execution has completed (the method has return),true
if execution was suspended.- Throws:
CoroutineException
- an exception occurred during execution of this coroutine, the saved execution stack and object state may be out of sync at this point (meaning that unless you know what you're doing, you should not callexecute()
again)
-
getContext
Get the context. Accessible via theContinuation
object that gets used by this coroutine.- Returns:
- context context
-
setContext
Set the context. Accessible via theContinuation
object that gets used by this coroutine.- Parameters:
context
- context
-
getCoroutine
Get the coroutine assigned to this runner.- Returns:
- coroutine assigned to this runner
-
getContinuation
Continuation getContinuation()
-