Class CoroutineRunner
java.lang.Object
com.offbynull.coroutines.user.CoroutineRunner
- All Implemented Interfaces:
Serializable
- Author:
- Kasra Faghihi
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanexecute()Starts/resumes execution of this coroutine.Get the context.Get the coroutine assigned to this runner.voidsetContext(Object context) Set the context.
-
Constructor Details
-
CoroutineRunner
Constructs aCoroutineRunnerobject.- Parameters:
coroutine- coroutine to run- Throws:
NullPointerException- if any argument isnull
-
-
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:
falseif execution has completed (the method has return),trueif 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 theContinuationobject that gets used by this coroutine.- Returns:
- context context
-
setContext
Set the context. Accessible via theContinuationobject that gets used by this coroutine.- Parameters:
context- context
-
getCoroutine
Get the coroutine assigned to this runner.- Returns:
- coroutine assigned to this runner
-