Package io.temporal.workflow
Interface CancellationScope
-
- All Superinterfaces:
java.lang.Runnable
- All Known Subinterfaces:
WorkflowThread
- All Known Implementing Classes:
RootWorkflowThreadImpl
public interface CancellationScope extends java.lang.RunnableHandle to a cancellation scope created throughWorkflow.newCancellationScope(Runnable)orWorkflow.newDetachedCancellationScope(Runnable). Supports explicit cancelling of the code a cancellation scope wraps. The code in the CancellationScope has to be executed usingRunnable.run()method.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcancel()Cancels the scope as well as all its childrenvoidcancel(java.lang.String reason)Cancels the scope as well as all its children.static CancellationScopecurrent()java.lang.StringgetCancellationReason()Promise<java.lang.String>getCancellationRequest()Use this promise to perform cancellation of async operations.booleanisCancelRequested()Is scope was asked to cancel throughcancel()or by a parent scope.booleanisDetached()When set to false parent thread cancellation causes this one to get canceled automatically.static voidthrowCanceled()ThrowsCanceledFailureif scope is canceled.
-
-
-
Method Detail
-
isDetached
boolean isDetached()
When set to false parent thread cancellation causes this one to get canceled automatically. When set to true only call tocancel()leads to this scope cancellation.
-
cancel
void cancel()
Cancels the scope as well as all its children
-
cancel
void cancel(java.lang.String reason)
Cancels the scope as well as all its children.- Parameters:
reason- human-readable reason for the cancellation. Becomes message of the CanceledException thrown.
-
getCancellationReason
java.lang.String getCancellationReason()
-
isCancelRequested
boolean isCancelRequested()
Is scope was asked to cancel throughcancel()or by a parent scope.- Returns:
- whether request is canceled or not.
-
getCancellationRequest
Promise<java.lang.String> getCancellationRequest()
Use this promise to perform cancellation of async operations.- Returns:
- promise that becomes ready when scope is canceled. It contains reason value or null if none was provided.
-
current
static CancellationScope current()
-
throwCanceled
static void throwCanceled() throws CanceledFailureThrowsCanceledFailureif scope is canceled. Noop if not canceled.- Throws:
CanceledFailure
-
-