public class Suspension<T>
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
Suspension(CoroutineStep<?,T> rSuspendingStep,
CoroutineStep<T,?> rResumeStep,
Continuation<?> rContinuation)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels this suspension.
|
Continuation<?> |
continuation()
Returns the continuation of the suspended coroutine.
|
void |
fail(java.lang.Throwable eError)
Cancels this suspension because of an error.
|
void |
ifNotCancelled(java.lang.Runnable fCode)
Executes code only if this suspension has not (yet) been cancel.
|
boolean |
isCancelled()
Checks if the this suspension has been cancelled.
|
void |
resume()
Resumes the execution of the suspended coroutine with the input value
provided to the constructor.
|
void |
resume(T rValue)
Resumes the execution of the suspended coroutine with the given value.
|
CoroutineStep<?,T> |
suspendingStep()
Returns the suspending step.
|
java.lang.String |
toString() |
T |
value()
Returns the value of this suspension.
|
Suspension<T> |
withValue(T rValue)
Sets the suspension value and returns this instance so that it can be
used as an updated argument to method calls.
|
protected Suspension(CoroutineStep<?,T> rSuspendingStep, CoroutineStep<T,?> rResumeStep, Continuation<?> rContinuation)
resume(Object)
can be used. If the resume
should occur at a different time than the availability of the input value
a suspension can be updated by calling withValue(Object)
. In
that case resume()
can be used later to resume the execution.rSuspendingStep
- The step that initiated the suspensionrResumeStep
- The step to resume the execution withrContinuation
- The continuation of the executionpublic void cancel()
cancel
the continuation. Tries to resuming a cancelled suspension will be
ignored.public final Continuation<?> continuation()
public void fail(java.lang.Throwable eError)
fail
the continuation. Tries to resume a
failed suspension will be ignored.eError
- The error exceptionpublic void ifNotCancelled(java.lang.Runnable fCode)
fCode
- The code to execute only if this suspension is not cancelledpublic final boolean isCancelled()
public final void resume()
resume(Object)
public void resume(T rValue)
rValue
- The input value to the resumed steppublic final CoroutineStep<?,T> suspendingStep()
public java.lang.String toString()
toString
in class java.lang.Object
public final T value()
public Suspension<T> withValue(T rValue)
rValue
- The new value